我有一个2D灰度图像(=数据),我试图用fcm.m进行分割:
Nc=2; %number of clusters is 2
[centers,U] = fcm(data,Nc);
如何应用fcm.m的输出来分割原始图像。我无法在网上找到一个有用的例子。
答案 0 :(得分:2)
只做reshape
:
img = im2double(imread('cameraman.tif'));
Nc = 2; %number of clusters is 2
[centers,U] = fcm(img(:),Nc);
subplot(121);
imshow(reshape(U(1,:),size(img)),[])
title('fuzzy membership for class 1')
colorbar()
subplot(122);
[~,I] = max(U,[],1);
imshow(reshape(I,size(img)),[])
title('hard membership')
colorbar()