From: Valentin Rabanelly on
Hi everybody!

I'm trying to classify data from a picture using nearest neighbor method (knnclassify).
The picture is artificially created from a satellite one.

The picture I'm using is here : http://www.mediafire.com/file/mrymnkmimzz/mixedChannels.tif
(thumbnail here : http://img708.imageshack.us/img708/3250/mixedchannels.png)
It's made it out of pictures from Landsat 7, with channels 3,4 and 5.
(from this picture : http://img155.imageshack.us/img155/5968/mixedchannelsfull.jpg)

I've cut 4 zones out of the original pictures from Landsat and my aim is to classify the data in it. These 4 zones correspond each one to a class.
So, basically, the picture is like this :
picture(0:100,0:100) = class1
picture(0:100,101:200) = class2
picture(101:200,0:100) = class3
picture(101:200,101:200) = class4
Every square with size 100x100 must contain the data from a class.

But now that I'm wanting to use the knnclassify function, I don't know what parameters to use.
At least, knnclassify has 3 arguments :
knnclassify(Sample, Training, Group)
Where :
- "Sample" is the data I want to classify
- "Training" is the training data
- "Group" is a vector whose distinct values define the grouping of the rows in "Training".
More informations here : http://www.mathworks.com/access/helpdesk/help/toolbox/bioinfo/ref/knnclassify.html

Could you please give me some clue?

Thank you!
From: Valentin Rabanelly on
Hi there!

Anyone to help please?

Thanks a lot!
From: Tom Lane on
> Anyone to help please?

I didn't understand your original question.

Are you saying that it just turns out that the four 100-by-100 areas in one
corner just happen to be representative of four classes, and that there are
many other 100-by-100 areas that you want to classify elsewhere in the
image?

The kknclassify function wants each thing to be classified to be represented
as a row of a matrix. You could create a new matrix with 1 row for each
100-by-100 area, and with 10000 columns that are the 10000 values in the
specified area. This would give you exactly one training sample per class.
But I don't understand the problem well enough to figure out if that's what
you're trying to do.

Another alternative would be for each pixel to be a training sample, so
you'd have 10000 training samples per class. But that would mean that, in
trying to choose the class for a pixel, you would make no use of nearby
parts of the image.

Sorry if this makes no sense -- I have no experience classifying images --
but I would need to understand your problem better in order to suggest how
you could use knnclassify.

-- Tom