how can i detect object using knn ?

i'm new to the maching learning..now i am working on my project which is building detection using image processing. i should apply knn and divide it in training and testing data set.. but in practically how to procced that's what i am not getting .please help me through this... please send steps.

Answers (1)

Image Analyst
Image Analyst on 2 Jan 2020
Edited: Image Analyst on 2 Jan 2020
For what it's worth, attached is a KNN demo, though for (x,y) points, not for an image.
For image processing, you need to decide upon what features you're going to use. What are you going to cluster on? What values are your reference set?

10 Comments

i have no idea obout that using matlab , my project exactly focusing on how to extract building from image using KNN , i need to know exactly how to declar the training samples and test samples for RGB image , i need code??
Here’s a great Albert Einstein quote:
“If I had an hour to solve a problem I’d spend 55 minutes thinking about the problem and five minutes thinking about solutions.”
If you don't know what you want to do with, or to, the image, then I certainly don't. Your question is far too vague for anyone to answer. See this link.
for that reason i am stucke , i asked for helping , the porpes is detecting building from a picture using KNN ,
-if can we solve such problem by KNN or not
-if there exist a code for detectiong object based on knn i want to see steps ,,,,..
yes that what i meant how to segment buildings from aerial or satellite photos ,but using matlab code. i know the mathematical way ,i just need a program or example like that for detectiong objects by knn in matlab thank you in advance
Okay, so which particular mathematical way are you using?
Yes, exactly what mathematical way. You said you know it, so what is it? And don't just say it's KNN because that's not sufficient. That's almost worthless. You might just as well say that you know how to do it because your know the method is "image segmentation", but that's so vague that it's totally worthless.
You DO know that KNN requires a list of features or attributes for each class don't you? So what are your features? What did you measure?
We don't have building segmentation function in MATLAB so you're going to have to write some code which means you'll probably have to read several of those papers (none of which we have code for) and see which seems promising for images like yours, and then code it up. If you don't know how, the Mathworks would be very happy to write it for you.
As for Walter and me, we can't develop the code for you. We'll help with small parts of your own code, or maybe contribute something original if it takes us just 5 or 10 minutes, but a project like you want would take many days, weeks or even longer. I'm sure Ph.D. dissertations have been written on the subject. Good luck though. It is possible since we see so many people have already done it and published it.
Well, you can do k-means clustering based upon RGB values, but techniques like that get thrown off by trivial detdetailsdetails like advertisement signs.
thank you @image_analyst i really appreciate your comments, i realized that i am really out of my work , i will try to understand knn method , then apply it for array of pixels , if i get any probelm i will post it thank you
For what it's worth (very little since kmeans is usually lousy, or at least not the best method, for intensity segmentation), I'm attaching my demo on using kmeans to do color segmentation.

Sign in to comment.

Asked:

on 2 Jan 2020

Commented:

on 10 Feb 2020

Community Treasure Hunt

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

Start Hunting!