%% Image segmentation by WFCM
% WFCM refer to 'Fuzzy cluster analysis and its application' by Teacher
% Gao, Published by xidian
% we first implement one thresholding segmentation, then auto
% multi-thresholding
% we also used two-dimentional gray histogram
% Algorithm by Teacher Xinbo Gao, implemented by Lin Zhao, VIPS Lab
%% Code Follows
clear
inputim = imread('TestImage\lena.bmp')
figure
% count 1D histogram or 2D histogram
[h,x] = imhist(inputim)
nst = imhist2(inputim)
count = 0:1:255
% count = nst
% compute the weighted coefficient wi
w = h'./sum(h')
% iteration to compute the center of clustering,here c=2
vc1 = 64
v1 = 0
while (abs(v1-vc1)>2)||(abs(v2-vc2)>2)
if n ~= 0
vc1 = v1
end
% update uij
for j = 1:1:2
if j == 1
vc = vc1
else
vc = vc2
end
end
% compute the threholding
t = (vc1+vc2)/2
T = repmat(t,size(inputim,1),size(inputim,2))
outputim = inputim>T
outputim = double(outputim)
figure



完整代码或者仿真咨询添加QQ1575304183