SOM Toolbox Online documentation http://www.cis.hut.fi/projects/somtoolbox/

som_kmeanscolor2

[color,centroids]=som_kmeanscolor2(mode,sM,C,initRGB,contrast,R)

 SOM_KMEANSCOLOR2 Color codes a SOM according to averaged or best K-means clustering

 color = som_kmeanscolor2('average',sM, C, [initRGB], [contrast],[R]) 

  color=som_kmeanscolor2('average',sM,[2 4 8 16],som_colorcode(sM,'rgb1'),'enhanced');
  [color,centroid]=som_kmeanscolor2('best',sM,15,[],'flat',R);
  
  Input and output arguments ([]'s are optional):

   mode       (string) 'average' or 'best', defalut: 'average'
   sM         (struct) a map struct
   C          (vector) number of clusters
   [initRGB]  (string, matrix) a color code string accepted by SOM_COLORCODE
               or an Mx3 matrix of RGB triples, where M is the number
               of map units. Default: SOM_COLORCODEs default
   [contrast] (string) 'flat', 'enhanced' color contrast mode, default:
               'enhanced'.
   [R]        (scalar) number of K-means trials, default: 30.
   color      (matrix) Mx3xC of RGB triples
   centroid   (array of matrices) centroid{i} includes codebook for the best
               k-means for C(i) clusters, i.e. the cluster centroids corresponding to
               the color code color(:,:,i).
 
 The function gives a set of color codes for the SOM according to K-means 
 clustering. It has two operation modes: 
 
 'average': The idea of coloring is that the color of the units belonging to the same 
   cluster is the  mean of the original RGB values (see SOM_COLORCODE) of the map units 
   belonging to the cluster (see SOM_CLUSTERCOLOR). The K-means clustering is made,
   by default, 30 times and the resulting color codes are averaged for
   each specified number of clusters C(i), i=1,...,k. In a way, the resulting averaged color 
   codes reflect the stability of the K-means clustering made on the map units.

 'best': runs the k-means R times for C(i), i=1,...,n clusters as in previous mode, 
   but instead of averaging all the R color codes, it picks the one that corresponds to the 
   best k-means clustering for each C(i). The 'best' is the one with the lowest 
   quantization error. The result may differ from run to run.

 EXAMPLE
 
  load iris; % or any other map struct sM 
  color=som_kmeanscolor2('average',sM,[2:6]);
  som_show(sM,'umat','all','color',color);
 
 See also SOM_KMEANS, SOM_SHOW, SOM_COLORCODE, SOM_CLUSTERCOLOR, SOM_KMEANSCOLOR



[ SOM Toolbox online doc ]