IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Kernel K-means algorithmSee full documentation
classesImg,clustersCentroidskernelKMeansImg (inImg,nbClusters,nbSamples)

Detailed Description

classifies pixels of an image using Kernel k-means algorithm

Kernel K-means algorithm consists in clustering a set of n points of d dimensions in k clusters.

This is an adaptation of the classical K-means which uses a radial basis kernel function to compute distances instead of the classical Euclidian distance.

This algorithm works in an augmented features space dimension to allow handling non linear clustering case such as follows :

KernelKMeansImg_graph.png

It also uses 'the kernel trick' to maintain reasonable feature space dimension and allows computation.

Applied here to image processing, for an input image $InHomogeneousImg$ of size {x, y, z, c, t}, with c the number of color channels and t the number of elements in temporal sequence, it will clusters :

For each attempt ( $InOptNbAttempts$ parameter) :

Clustering result with the best separation value, which is defined by Dunn validity index (see ipsdk::math::clustering::eValidityIndexType), will be retained and stored into $OutKKMeansCentroids$.

Finally, a clustering assignment using the 'best' clustering result on sample value will be computed on whole input image to generate $OutClassImg$.

Note
$InOptKernelKMeansParams$ contains the parameters allowing automatic computation of radial basis kernel sigma value and accuracy threshold used during linear dependency analysis.

Here is an example of Kernel K-means based classification :

KernelKMeansImg.png
See also
The Kernel Recursive Least Squares Algorithm, Yaakov Engel, Shie Mannor, Ron Meir, 2003
The Global Kernel k-Means Clustering Algorithm, Grigorios Tzortzis and Aristidis Likas, Department of Computer Science, University of Ioannina, GR 45110, Ioannina, Greece.
https://en.wikipedia.org/wiki/Support_vector_machine

Example of Python code :

Example imports

Code Example

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLClassification/Processor/KernelKMeansImg/KernelKMeansImg.h>

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// computation of Kernel KMeans clustering with default parameters
const ipUInt32 nbSamples = 5000;
KernelKMeansResults res1 = kernelKMeansImg(pInImg, nbClusters, nbSamples);
// computation of Kernel KMeans clustering with custom parameters
const ipUInt32 nbAttempts = 5;
const ipReal32 sigmaParam = 0.1f;
const ipReal32 accuracyThresholdParam = 0.001f;
sigmaParam, accuracyThresholdParam);
ImagePtr pOutImg2 = createImage(*res1._pClassesImg);
KKMeansCentroidsPtr pOutKKMeansCentroids(boost::make_shared<KKMeansCentroids>());
kernelKMeansImg(pInImg, nbClusters, nbSamples, nbAttempts, pKernelKMeansParams, pOutImg2, pOutKKMeansCentroids);