PANDORE Version 6 GREYC-IMAGE

pkmeans



Performs K-means clustering on a set of objects.



Synopsis

pkmeans attr_in attr_out k maxiter [col_in|-] [col_out|-]

Description

pkmeans classifies a given set of objects into K clusters from their features. The object features are specified into col_in as a set of vectors attr_in.1, attr_in.2, ..., attr_in.n.

K-means is a partitioning method for a group of n objects into k clusters which uses the following steps:

  1. Place k points into the space represented by the objects that are being clustered. These points represent initial group centroids.
  2. Assign each object to the group that has the closest centroid.
  3. When all objects have been assigned, recalculate the positions of the K centroids.
  4. Repeat steps 2 and 3 until the centroids no longer move. This produces a separation of the objects into groups from which the distance to be minimized can be calculated.

The distance measure between an object i and the cluster center Cj uses the euclidean distance:

    Dij = [ SUM{d=1;n} (xid - Cjd )2 ] 1/2

where xid is the feature d for the object i and cjd is the feature d for the centroid Cj.

Parameters

Inputs

Outputs

Result

Returns SUCCESS or FAILURE.

Examples

Segments the tangram.pan image thanks to a K-means clustering of the pixels based on mean and variance features:

   pmeanfiltering 1 tangram.pan moy.pan
   pvariancefiltering 0 255 tangram.pan var.pan

   pim2array data.1 moy.pan data1.colc
   pim2array data.2 var.pan data2.colc
   parray2array data.1 Float data1.colc data1.cold
   parray2array data.2 Float data2.colc data2.cold
   pcolcatenateitem data1.cold data2.cold data3.cold
   parraysnorm data data3.cold data3.cold

   pkmeans data attrib 5 100 data3.cold cluster.cold

   pproperty 0 tangram.pan
   w=`pstatus`
   pproperty 1 tangram.pan
   h=`pstatus`

   parray2im $h $w 0 attrib cluster.Cold kmeans.pan
   pim2rg kmeans.pan classif1_out.pan

See also

Classification

C++ prototype

Errc PKmeans( const std::string &a_in, const Collection &c_in, const std::string &a_out, Collection &c_out, int k, int max );

Version française

Classification automatique selon les K-moyennes.


Author: Alexandre Duret-Lutz