A list,

FLICM algorithm is a robust image segmentation algorithm based on fuzzy clustering of local spatial information.

1 Steps of FLICM algorithm



Ii. Source code

clear all;
clc;
image = load('im.txt');
%image = imread('017.jpg');
[row,col,channels] = size(image);

if (channels > 1)
    image = rgb2gray(image);
    figure;
    imshow(image);
    title('Original image')
else
    figure;
    imshow(image);
    title('Original image'Originimg =image; originimg=mat2gray(originimg); [ori_row,ori_col]=size(originimg); sigma =1.6; %sigma assigns N =7; % size is (2N+1) x (2N+1N_row =)2*N+1; 
OriImage_noise = imnoise(originimg,'gaussian'); % denoising gausFilter = fSpecial ('gaussian',[N_row N_row],sigma); Img =imfilter(OriImage_noise,gausFilter,'conv');
%figure;
%imshow(img);
%title('After Gaussian filtering') key_mat = []; % define an empty key pixel matrix non_key_mat = []; % non-critical pixel matrixfor i = 2:3:row
    for j = 2:3:col
        if row-i<1|col-j<1
            continue;
        end
        window_image = img(i- 1:i+1,j- 1:j+1); [r,c] = size(window_image); max_value = max(max(window_image)); % window Max [x,y] = find(window_image==max_value); key_mat = [key_mat;[i2 -+x(1),j2 -+y(1),max_value]];
        img(i2 -+x(1),j2 -+y(1=))- 1;
%         for m = 1:r
%             for n = 1:c
%                 non_key_mat = [non_key_mat;i2 -+m,j2 -+n,window_image(m,n)];
%             end
%         end
    end
end
[r,c]=find(img ~=- 1);
value = (img(find(img ~=- 1)));
non_key_mat = [r c value];
% for m = 1:row
%     for n = 1:col
%         tmp = [m,n,img(m,n)];
%         if ismember(tmp,key_mat,'rows') = =1
%             continue;
%         end
%         non_key_mat = [non_key_mat;tmp];
%     end
% end

New_img = key_mat(:,3);
New_coord = key_mat(:,1:2);
cNum = 2;
m = 2;
winSize = 5;
maxIter = 59;
thrE    = 0.00001;
% FLICM
[imOut,iter] = FLICM_clustering( New_img, cNum, m, winSize, maxIter, thrE );
imOut = double(imOut);
key_mat = [key_mat imOut];
figure;
gscatter(key_mat(:,1),key_mat(:,2),imOut);
size(non_key_mat);
size(key_mat);
key_mat;
%key_mat = sortrows(key_mat,[1 2])
%img(find(img==- 1));
% [xx,yy] = find(img ==- 1);
% key = sortrows([yy xx],1)
% img(find(img==- 1)) = key_mat(:,4)
for i = 1:size(non_key_mat,1)
    z = ones(1,size(key_mat,1))*non_key_mat(i,1);
    z=z';
   
    zc = ones(1,size(key_mat,1))*non_key_mat(i,2);
    zc=zc';
    size(key_mat(:,1));
    dis = (z-key_mat(:,1)).* (z-key_mat(:,1))+(zc-key_mat(:,2)).*(zc-key_mat(:,2));
    dis = sqrt(dis);
    [labelx,labely] = min(dis);
    dis = sort(dis);
    xx = key_mat(labely,:);
    img(non_key_mat(i,1),non_key_mat(i,2)) = xx(4);
end

for j = 1:size(key_mat,1)
    img(key_mat(j,1),key_mat(j,2)) = key_mat(j,4);
    
end
Copy the code

3. Operation results





Fourth, note

Version: 2014 a