如何申请Matlab的模糊C均值(FCM)输出用于图像分割
问题描述:
我有我使用fcm.m试图区段的2D灰度图像(=数据):如何申请Matlab的模糊C均值(FCM)输出用于图像分割
Nc=2; %number of clusters is 2
[centers,U] = fcm(data,Nc);
如何申请fcm.m的输出来分割原始图像。我找不到在线的工作示例。
答
只是做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()