IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

classifies pixels of an image using Kernel k-means algorithm More...

IPSDKIPLCLASSIFICATION_API KernelKMeansResults ipsdk::imaproc::classif::kernelKMeansImg (const image::ImageConstPtr &pInImg, const ipUInt32 nbClusters, const ipUInt32 nbSamples)
 wrapper function for Kernel KMeans clustering algorithm More...
 
IPSDKIPLCLASSIFICATION_API void ipsdk::imaproc::classif::kernelKMeansImg (const image::ImageConstPtr &pInImg, const ipUInt32 nbClusters, const ipUInt32 nbSamples, const ipUInt32 nbAttempts, const attr::KernelKMeansParamsConstPtr &pKernelKMeansParams, const image::ImagePtr &pOutClassImg, const attr::KKMeansCentroidsPtr &pOutKKMeansCentroids)
 wrapper function for Kernel KMeans clustering algorithm More...
 

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InHomogeneousImg [Input] Homogeneous image X
ipsdk::imaproc::attr::InNbClusters [Input] Number of clusters X
ipsdk::imaproc::attr::InNbSamples [Input] number of samples for processing operation X
ipsdk::imaproc::attr::InOptNbAttempts [Input Optional] Number of times k-means is executed using different initial clusters centers X
ipsdk::imaproc::attr::InOptKernelKMeansParams [Input Optional] parameters for kernel kmeans clustering algorithm X
ipsdk::imaproc::attr::OutClassImg [Output] Image of classes customOutput (_pOutClassImg, outputKernelKMeans(_pInHomogeneousImg,_pInNbClusters))
ipsdk::imaproc::attr::OutKKMeansCentroids [Output] collection of kernel cluster centroid representation allocate (_pOutKKMeansCentroids)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::customImageProperty (_pOutClassImg,
 matchKernelKMeansClassImg (_pInHomogeneousImg,_pInNbClusters))

Example of Python code :

Example imports

Code Example

Example of C++ code :

Example informations

Associated library

IPSDKIPLClassification

Header file

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);
See also
KernelKMeansImgLvl1

Function Documentation

◆ kernelKMeansImg() [1/2]

IPSDKIPLCLASSIFICATION_API KernelKMeansResults ipsdk::imaproc::classif::kernelKMeansImg ( const image::ImageConstPtr pInImg,
const ipUInt32  nbClusters,
const ipUInt32  nbSamples 
)

wrapper function for Kernel KMeans clustering algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ kernelKMeansImg() [2/2]

IPSDKIPLCLASSIFICATION_API void ipsdk::imaproc::classif::kernelKMeansImg ( const image::ImageConstPtr pInImg,
const ipUInt32  nbClusters,
const ipUInt32  nbSamples,
const ipUInt32  nbAttempts,
const attr::KernelKMeansParamsConstPtr pKernelKMeansParams,
const image::ImagePtr pOutClassImg,
const attr::KKMeansCentroidsPtr pOutKKMeansCentroids 
)

wrapper function for Kernel KMeans clustering algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure