MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by FIR
on 31 Jan 2013

I have a image below

http://imgur.com/RsRHy2V

here i have detected surf features and have draw circle over it,now i want to apply k means for that surf features inside that blue circle,please assist

for whole image i used code

cform = makecform('srgb2lab'); lab_he = applycform(I,cform);

he=I; ab = double(lab_he(:,:,2:3)); nrows = size(ab,1); ncols = size(ab,2); ab = reshape(ab,nrows*ncols,2);

nColors = 3; % repeat the clustering 3 times to avoid local minima [cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ... 'Replicates',3);

but how to apply for surffeatures inside circle

*No products are associated with this question.*

Answer by Image Analyst
on 31 Jan 2013

Get a mask for each circle (say by using code from the FAQ) and then get the pixel values inside by doing:

pixelValuesInsideCircle = grayImage(circleMask);

## 4 Comments

## Lester Lim (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/60655#comment_126220

http://www.princeton.edu/~kung/ele571/571-MatLab/571BP_Chad/kmeans.m

## FIR (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/60655#comment_126224

how to select those surf features

## Lester Lim (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/60655#comment_126231

use roipoly, after drawing the ROI, double click it to give mask...

## FIR (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/60655#comment_126240

but rioploy gives a binary image , i need to apply k means surf features