%% 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;clc;close all;
inputim = imread('TestImage\lena.bmp'); inputim = rgb2gray(inputim);
figure;imshow(inputim,[]);
% count 1D histogram or 2D histogram
[h,x] = imhist(inputim); figure;stem(x,h);
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; vc2 = 192; % initialization
v1 = 0; v2 = 0; n = 0;
while (abs(v1-vc1)>2)||(abs(v2-vc2)>2)
    if n ~= 0
        vc1 = v1; vc2 = v2;
    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;imshow(outputim,[]);
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.

【图像分割】基于WFCM算法的图像分割matlab源码_图像处理

【图像分割】基于WFCM算法的图像分割matlab源码_matlab_02

【图像分割】基于WFCM算法的图像分割matlab源码_matlab_03