function out= fcmseg5(a)

a=double(a);

%a=a(500:1500,500:2000);

aa=conv2(a,ones(3)/9,'same');
data = [a(:) aa(:)];
c=3; %numarul claselor
[center, u, obj_fcn]=fcm(data,c,[2 20 1e-5 1]);

miu_cls = [0 0 0];
for i=1:3
    miu_cls(i) = mean ( a ( find (reshape(u(i,:),size(a)) > 0.5) ) );
end

miu_sorted = sort (miu_cls);

prot    = reshape(u( find(miu_cls == miu_sorted(3)) ,:),size(a));
os      = reshape(u( find(miu_cls == miu_sorted(2)) ,:),size(a));
back    = reshape(u( find(miu_cls == miu_sorted(1)) ,:),size(a));

% find(prot)>0.4
% pause

% prot(find(prot>0.6)) = 1;
% prot(find(prot<=0.6)) = 0;
% 
% os(find(os>0.5)) = 1;
% os(find(os<=0.5)) = 0;

out=back;
%figure,imagesc(prot),colormap(gray(256)),axis image
%figure,imagesc(os),colormap(gray(256)),axis image
%figure,imagesc(back),colormap(gray(256)),axis image
% pause

% out=prot-prot;
% out(find(prot==1))=64;
% out(find(os==1))=128;
% figure,imagesc(out),colormap(gray(256))