• Tidak ada hasil yang ditemukan

Fuzzy C Means algorithm (FCM) image segmentation MATLAB program C C Program Develop

N/A
N/A
Protected

Academic year: 2017

Membagikan "Fuzzy C Means algorithm (FCM) image segmentation MATLAB program C C Program Develop"

Copied!
3
0
0

Teks penuh

(1)

Fuzzy C­Means algorithm (FCM) image

segmentation MATLAB program

Tag: the matlab, OUTput, image, c the

 

Category: C

 

Author: linxiyyz

 

Date: 2013­11­24

Fuzzy C­Means algorithm (FCM) image segmentation MATLAB program

The subject used Fuzzy C­Means (FCM) algorithm image segmentation, write a MATLAB program to friends in need, for reference only. If wrong with that, and hope to be enlighten.

% File name: FCM.m 

% Function: Fuzzy C­Means (FCM) clustering algorithm for image segmentation  %: Rain curtain 

% Time: 11/17/2011

Image%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FCM algorithm for segmentation  function clusterResult = FCM (imagePath, C, V, M, iter, epsm) 

Fuzzy C­Means (FCM) clustering algorithm for image segmentation  % ClusterResult = FCM (imagePath, C, V, M, iter, epsm) 

% Example: clusterResult = FCM ('E: \ Image \ lena.bmp')  % ClusterResult = FCM ('E: \ Image \ lena.bmp', 3, [0 127 255])  % Input: 

% ImagePath: image path 

% C: the number of categories, the default value of 2  % V: initialize the cluster center, the default value [0255]  % M: weighted index, the default value of 2 

% Iter: number of iterations, the default value is 100 

For% epsm: iteration stops threshold, the default value is 1.0E­2  % Output: 

The% clusterResult: clustering results  % Note: 

The value of% C and V initialization of cluster centers % Set the default value 

if nargin <6  epsm = 1.0e­2;  end

if nargin <5  iter = 100;  end

if nargin <4  M = 2;  end

if nargin <3  V = [255];  end

if nargin <2  C = 2;  end

(2)

I = imread (ImagePath);  figure, imshow (I);  title ('original image');  [Row col] = size (I);  grayHist = imhist (I);  the figure, imhist (I);  title ('histogram'); 

histProb = grayHist / (row * col);  len = length (histProb);

tic 

% FCM iterative process  cnt = 0; 

while (cnt <iter) 

% Of the membership function (note that special consideration to the case of a pixel and the cluster center)  for i = 1: len 

flag = 0;  for j = 1: C  if i == V (j),  U (j, i) = 1.0;  if j == 1 

U (j + 1: C, i) = 0.0;  elseif j == C 

U (1: C ­ 1, i) = 0.0;  else 

U (1: j ­ 1, i) = 0.0;  U (j + 1: C, i) = 0.0;  end 

flag = 1;  break;  end  end 

if flag == 0 

u = (1.0. / ((i ­ V). ^ 2)). ^ (1.0 / (M ­ 1));  uSum = sum (u); 

U (1: C, i) = u '/ uSum;  end 

end 

% Updating various cluster center  for j = 1: C 

i = linspace (1, len, len); 

v = sum (histProb '. * i. * (U (j, :). ^ M));  vSum = sum (histProb '. * (U (j, :). ^ M));  if vSum == 0 

clusterResult (j) = 0;  else 

clusterResult (j) = v / vSum;  end 

end 

(3)

if diff <= epsm  break; 

else 

V = clusterResult;  end 

cnt = cnt + 1;  end 

toc

% Image segmentation  for i = 1: row 

for j = 1: col 

temp = (double (I (i, j)) ­ clusterResult). ^ 2;  [Fmin pos] = min (temp); 

I (i, j) = pos * 255 / C;  end 

end 

figure, imshow (uint8 (I)); 

title ('after the segmentation of the image');  disp ('the number of iterations of: iterTimes =');  disp (CNT); 

Referensi

Dokumen terkait

Sehubungan dengan dilaksanakannya Evaluasi Penawaran yang dilakukan oleh Pokja I Unit Layanan Pengadaan Barang/Jasa Pemerintah Kabupaten Merangin Lingkup Dinas Pekerjaan Umum

Mengingat pentingnya acara ini, diharapkan kehadiran Direktur Perusahaan dan/atau Wakil yang ditunjuk sesuai persyaratan Dokumen Kualifikasi paket ini. Demikian penyampaian

Sehubungan dengan telah selesainya Evaluasi Penawaran dan Evaluasi Kualifikasi yang dilakukan oleh POKJA III Unit Layanan Pengadaan Barang/ Jasa Kabupaten Merangin Lingkup

Pokja III Pekerjaan Konstruksi dan Jasa Konsultansi Unit Layanan Pengadaan (ULP) Barang dan Jasa.

Jika tidak ada sanggahan atau sanggahan ditolak maka peserta yang masuk dalam daftar pendek dapat mengunduh (download) Dokumen Pemilihan untuk memasukkan

When you close the door that leads to your personal mysteries, you deprive yourself of a source of power and passion?. One way to reopen that door, or open it wider, is to embrace

All these form a crowd for us not in the dictionary sense, but let us say that we are always getting connected with someone, somewhere and are not living on an island alone.. Even

This study aims to obtain of entrepreneurial that have characterized students; enhance the entrepreneurial passion of the character students through