Shape Recognition with kNN

I want to do a shape recognition program in Matlab with the KNN algorithm. But I couldn't. I searched everything about that, but i couldn't find anything. I have to make a program that classifies and recognizes square, circle and triangle with kNN algorithm. I need it urgently. I'm glad you helped me.

3 Comments

Yes you are right about that. But I I do not threaten anyone. I just wanted to state what was in a hurry. I did not force anyone.
Do you share accommodation with anyone?
Would you accept the other(s) regularly saying, "I can't cook or do any housework or go shopping for the things we ran out of, because a student needs me to do their research for them, they left it late and now it's urgent" ?
Because I live with university teaching staff, and they have an even larger supply of last-minute "it's urgent" students than I do.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 7 May 2018
I have a demo that counts vertices but it doesn't use KNN because it doesn't need to. I don't even know how you'd use KNN in this context. Why do you need code that specifically uses KNN? I've attached demos.

10 Comments

Yes you are absolutely right. I found something about shape recognition without kNN but in this situation they want with kNN. I presume they want me to learn the algorithm of kNN. So I need to with kNN. Thanks for your answer.
Who is "they"? If "they" want you to use knn, did they give any sort of hint as to which feature you should cluster? Like you can use gray level only if you have something like computer graphics where all squares are one gray level and all triangles are some other gray level. You can't use the number of vertices as your feature, because if you already knew that, you'd be done and wouldn't need to even use KNN at all. So what feature do you want to do cluster analysis on?
I take pattern recognition lesson in my university. They gave me this project to learn Knn's algorithm. but I did not find anything despite researching everything. they do not want anything too complicated. Just they want a project that only recognizes triangular, square and round shapes with knn.
Did they give you an image to use? Can you attach it? Maybe that will give us some clue as to what to cluster on.
They didn't give any image, also I will try 100 image :) maybe they want like this image and find shape of triangle, circle .. https://goo.gl/images/czqEce
I suggest you get more clarity on what image(s) you're supposed to use and what feature they think you can cluster on. Otherwise you're just guessing.
for i = 1:99 path = strcat('filepath', num2str(i),'.bmp'); img = imread(path); imgs(i) = img(:); end
there is an error in imgs(i) = img(:); line ;;Conversion to cell from uint8 is not possible. Can you help me urgently in 30 minutes ?
And you should not need to store all those images in a cell array, which you aren't even doing because you're using parentheses instead of braces. Plus not sure why you're converting the img to a column vector by doing (:) -- why???
Actually I dont know :) my friend told me. I solved problem with {} :) but I didn't do that anyway:( I need to read 100 images about Square,triangle and circle. Then I must use kNn but I can't do it :(
Yes, but you don't need to store all the images in memory at the same time in a cell array. You can read one, analyze it, then re-use the same variable on the next loop iteration. That is much more memory efficient. No need to keep storing images that you're already done processing, right?
And if you can't tell me what features to cluster on, then I can't help you with KNN, because I can't think of what they would be. Please post a picture if you can of some of the images you plan on reading in.

Sign in to comment.

Asked:

on 7 May 2018

Commented:

on 13 May 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!