天天看點

【圖像分割】基于遺傳算法的進化聚類技術對彩色圖像進行分割(Matlab代碼實作)

💥💥💥💞💞💞歡迎來到本部落格❤️❤️❤️💥💥💥

🏆部落客優勢:🌞🌞🌞部落格内容盡量做到思維缜密,邏輯清晰,為了友善讀者。

⛳️座右銘:行百裡者,半于九十。

目錄

​​💥1 概述​​

​​📚2 運作結果​​

​​🎉3 參考文獻​​

​​👨‍💻4 Matlab代碼實作​​

💥1 概述

       圖像分割是圖像分析和模式識别的首要問題,也是圖像處理的經典難題之一,它是圖像分析和模式識别系統的重要組成部分,并決定圖像的最終分析品質和模式識别的判别結果。所謂圖像分割是指将圖像中具有特殊意義的不同區域分開來,并使這些區域互相不相交,且每個區域應滿足特定區域的一緻性條件。

      由于彩色圖像提供了比灰階圖像更為豐富的資訊,是以彩色圖像處理正受到人們越來越多的關注。彩色圖像分割是彩色圖像處理的重要問題,彩色圖像分割可以看成是灰階圖像分割技術在各種顔色空間上的應用,為了使該領域的研究人員對目前各種彩色圖像分割方法有較全面的了解,是以本文基于遺傳算法(聚類)進行彩色圖像分割.

📚2 運作結果

使用基于遺傳算法的圖像分割 進化聚類

目标函數:在聚類距離内 使用距離測量

測量圖像特征:3個特征(R,G,B值)

它還由基于矩陣的輸入樣本示例組成 15 和 2 特征

【圖像分割】基于遺傳算法的進化聚類技術對彩色圖像進行分割(Matlab代碼實作)
【圖像分割】基于遺傳算法的進化聚類技術對彩色圖像進行分割(Matlab代碼實作)

部分代碼:

clc;
 clear;
 close all;%% Problem Definition
X = [1 1.5;2 2.5;3 3.5;1 1.5;2 2.5;3 3.5;1 1.5;2 2.5;3 3.5;1 1.5;2 2.5;3 3.5;1 1.5;2 2.5;3 3.5]; % [15x2]
 k = 3; % no. of clustersCostFunction=@(m) ClusteringCost(m, X);     % Cost Function m = [3x2] cluster centers
VarSize=[k size(X,2)];  % Decision Variables Matrix Size = [3 2]
nVar=prod(VarSize);     % Number of Decision Variables = 6
VarMin= repmat(min(X),1,k);      % Lower Bound of Variables [3x1] of[1x2] = [3x2]
 VarMax= repmat(max(X),1,k);      % Upper Bound of Variables [3x1] of[1x2] = [3x2]% Setting the Genetic Algorithms
ga_opts = gaoptimset('display','iter');
% running the genetic algorithm with desired options
 [centers, err_ga] = ga(CostFunction, nVar,[],[],[],[],VarMin,VarMax,[],[],ga_opts); m=centers;
    g=reshape(m,2,3)'; % create a cluster center matrix(3(clusters) points in 2(features) dim plane)=[3x2]
     d = pdist2(X, g); % create a distance matrix of each data points in input to each centers = [15x3]    % Assign Clusters and Find Closest Distances
     [dmin, ind] = min(d, [], 2)
     % ind value gives the cluster number assigned for the input = [15x1]
     
     % Sum of Within-Cluster Distance
     WCD = sum(dmin); 
     
     z=WCD; % fitness function contain sum of each data point to their corresponding center value set (aim to get it minimum)    
     % z = [1(inputs combinations) x 1]      

🎉3 參考文獻

👨‍💻4 Matlab代碼實作

繼續閱讀