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 :
It also uses 'the kernel trick' to maintain reasonable feature space dimension and allows computation.
Applied here to image processing, for an input image
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 :
- the x*y pixels for a 2d image
- the x*y*z voxels for a 3d image of c*t dimensions in
clusters.
For each attempt (
parameter) :
- Since time complexity of this algorithm is quite large, the input image data are sampled for clustering training stage.
image values will be samples to random image coordinates. Each sample will then agregate images values along color and temporal plans and will be used as a features vector.
- A clustering operation will then be proceeded using the class ipsdk::math::KernelKMeansClustering<RadialBasisKernel> with the parameters provided by
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
.
Finally, a clustering assignment using the 'best' clustering result on sample value will be computed on whole input image to generate
.
- Note
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 :
- 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
const ipUInt32 nbSamples = 5000;
KernelKMeansResults res1 = kernelKMeansImg(pInImg, nbClusters, nbSamples);
const ipUInt32 nbAttempts = 5;
const ipReal32 sigmaParam = 0.1f;
const ipReal32 accuracyThresholdParam = 0.001f;
sigmaParam, accuracyThresholdParam);
kernelKMeansImg(pInImg, nbClusters, nbSamples, nbAttempts, pKernelKMeansParams, pOutImg2, pOutKKMeansCentroids);