Advertisement
pongfactory

K-means Fixed Clustering Code [Kao-v1]

Jan 29th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.59 KB | None | 0 0
  1. % Comment: Classify the Colors in 'a*b*' Space Using Fixed K-Means Clustering
  2.     ab = double(rgb_he(:,:,2:3));
  3.     ab_all_band = double(rgb_he(:,:,2:3));
  4.     nrows = size(ab,1);
  5.     ncols = size(ab,2);
  6.     ab = reshape(ab,nrows*ncols,2);
  7.      
  8.     nColors = 3;
  9.     [cluster_idx, cluster_center] = kmeans(ab,nColors, ...
  10.                                     'Replicates',1, ...
  11.                                     'Options',opts, ...
  12.                                     'start',[118 143; 127 140; 133 127]);
  13. % Define A*B color on each cluster. (this example have 3 cluster)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement