I = imread('D:matlab7.1toolboximagesimdemoscameraman.tif');%%假设I为灰度图像
J = imnoise(I,'salt & pepper',0.02);%%添加椒盐噪声
J1=medfilt2(J,[3 3]);%%
X=[J1(:) I(:)];
Y=double(X);
[center,U,obj_fcn] = FCMClust(Y,2);
maxU = max(U);
index1 = find(U(1,:) == maxU);
index2 = find(U(2,:) == maxU);
[m,n]=size(J1);
J2=zeros(m*n,1);
J2(index1)=200;
J2(index2)=100;
J3=reshape(J2,m,n);
imshow(uint8(J3));