How to make output from FCM consistent (Fuzzy c-means clustering)?
2 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
[Problem]
I have 'brain' dicom image. I need to segment it into 3 clusters. I used the FCM method (code given bellow). It is a 3 level FCM thresholding. When I apply it to the images, I am getting 3 clusters, but all the time images appear in different figures. So I'm can't use fcmImage(index1{1,1}), for the next step as in the next time the fcmImage(index1{1,1}) can be replaced with some other index, for example with fcmImage(index1{1,2}).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151521/image.jpeg)
[Code Used]
close all; clear all; clc;
I = im2double(imread('brain.jpg'));
I = imadjust(I);
data = [I(:)];
%Number of clusters
num_clust = 3;
% Fuzzy C-means classification with 3 classes
[center,U,obj_fcn] = fcm(data,num_clust);
% Finding the pixels for each class
maxU = max(U);
fcmImage(1:length(data))=0;
for n_c= 1:num_clust
index1{n_c} = find(U(n_c,:) == maxU);
end
% Assigning pixel to each class by giving them a specific value
fcmImage(index1{1,1})= 0.9;
fcmImage(index1{1,2})= 0.5;
fcmImage(index1{1,3})= 0.3;
[M,N] = size(I);
% Reshapeing the array to a image
imagNew = reshape(fcmImage,M,N);
figure;imshow(imagNew,[]);
%figure;imshow(I,[]);
So here is there randomized outputs images:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151522/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151523/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151524/image.jpeg)
[Need] How to make output from FCM more consistent, is there any sort of labeling.
[Matlab version] R2015b
[Acknowledgement] Thanks in advance for any help. I will vote for all your answers.
@Image Analyst
@Walter Roberson
2 个评论
Fadhil M
2021-7-27
I have the same problem here, i've tried to constantly set the initial membership matrice by rng() function, and either using fixed initial centroid. both still returning inconsistent output (output centers seems to randomly assigned, not sorted). anyone knows why??
Diboun Mohsen Djawad
2021-9-8
use: rng('default');
like just before : rand ... or something
it will work just make sure your Matlab version is not too old:)
回答(1 个)
Dayangku Nur Faizah Pengiran Mohamad
2017-2-8
How to find thresholding in FCM code?
[ctr,class]=fcm(data,2);
Do you how to find inner code for fcm from MATLAB?
1 个评论
Pallavi Saha
2017-9-14
The output of the fcm is constantly changing, any ideas in this regard will be helpful
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Clustering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!