我在灰度图像上应用了kmeans Matlab函数(5个聚类)。我的问题是如何获得感兴趣的地区? 我的意思是如何使用下面的Matlab源代码定义结果imf(我应该选择哪个索引)?
function imf=selectRoi(I)
c=5;
H = fspecial('gaussian');
I = double(imfilter(I,H,'replicate'));
I=double(I);
IN=reshape(I, [], 1);
[iDX nn] = kmeans(IN,5);
imIDX=reshape(iDX, size(I));
imf=imIDX==4;
figure;
subplot(241); imshow(I); title('Original');
subplot(243); imshow(imIDX==1, []);title(['Kmeans',' : ',num2str(1)]);
subplot(244); imshow(imIDX==2, []);title(['Kmeans',' : ',num2str(2)]);
subplot(245); imshow(imIDX==3, []);title(['Kmeans',' : ',num2str(3)]);
subplot(246); imshow(imIDX==4, []);title(['Kmeans',' : ',num2str(4)]);
subplot(247); imshow(imIDX==5, []);title(['Kmeans',' : ',num2str(5)]);
end.