1
skin cancer image 我想申請K爲灰度圖像的聚類,代碼如下如何在灰度圖像應用k均值聚類在MATLAB
im = imread('SSM1_2_orig.jpg');
im = rgb2gray(im);
[idx centroids]=kmeans(double(im(:)),3,'distance','sqEuclidean','Replicates',3);
%imseg = zeros(size(im,1),size(im,2));
%{for i=1:max(idx)
%imseg(idx==i)=i;
%end}
segmented_images = cell(1,3);
for k = 1:3
color = im;
color(im ~= k) = 0;
segmented_images{k} = color;
end
figure(),imshow(segmented_images{1});
figure(),imshow(segmented_images{2});
figure(),imshow(segmented_images{3});
,但它給了我黑色的輸出僅
你試過'imshow(segmented_images {1},[]);' –
是的,但它給人的黑色輸出僅 –
那麼能否請您添加原始圖像,所以我們可以嘗試一下呢? –