IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Clusters centroids computation algorithm

Compute clusters centroids given an input image and the image of classes. More...

IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pClassImg)
 wrapper function for Compute clusters centroids given an input image and the image of classes More...
 
IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pClassImg, const ipsdk::image::ImageConstPtr &pMaskImg)
 wrapper function for Compute clusters centroids given an input image and the image of classes More...
 
IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pClassImg, const ipUInt32 nbClusters)
 wrapper function for Compute clusters centroids given an input image and the image of classes More...
 
IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pClassImg, const ipsdk::image::ImageConstPtr &pMaskImg, const ipUInt32 nbClusters)
 wrapper function for Compute clusters centroids given an input image and the image of classes More...
 

Detailed Description

Compute clusters centroids given an input image and the image of classes.

Consider:

The algorithm computes the properties of each cluster, namely the centroids, the standard deviation along each dimension and the compactness. For empty clusters, centroids coordinates are set to 0.

Input and output attributes of the algorithm are:

Note
A mask can be provided to use only a subset of pixels/voxels during the calculation.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InHomogeneousImg [Input] Homogeneous image X
ipsdk::imaproc::attr::InClassImg [Input] Image of classes X
ipsdk::imaproc::attr::InOptSingleGreyMaskImg [Input Optional] Binary image for masking operation for each (x, y, z) coordinate regardless to (c, t) coordinates X
ipsdk::imaproc::attr::InOptNbClusters [Input Optional] Number of clusters X
ipsdk::imaproc::attr::OutClustersCenters [Output] Centers of clusters ipsdk::processor::allocate (_pOutClustersCenters)
ipsdk::imaproc::attr::OutOptNbEltsPerCluster [Output Optional] Number of elements per cluster X

Global Rule description

Global rule description for algorithm :
ipsdk::processor::If (
 ipsdk::processor::isSet (_pInOptSingleGreyMaskImg),
 ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_3d,_pInHomogeneousImg,_pInOptSingleGreyMaskImg),
 ipsdk::processor::none ())

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLClassification as classif

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# opening of input class image
inClassImg = PyIPSDK.loadTiffImageFile(inputClassImgPath)
# apply "compute centers" algorithm
outClustersCenters = classif.kMeansComputeCenters(inImg, inClassImg)
# Access to the first cluster center
firstClusterCenter = outClustersCenters.coll[0].elements

Example of C++ code :

Example informations

Associated library

IPSDKIPLClassification

Header file

Code Example

ImagePtr pInImg = loadTiffImageFile(inputImgPath);
ImagePtr pInClassImg = loadTiffImageFile(inputClassImgPath);
const ipUInt64 nbExpectedClusters = 4;
// apply clusters centers computation algorithm
ClustersCentersPtr pOutClustersCenters = classif::kMeansComputeCenters(pInImg, pInClassImg, nbExpectedClusters);
// Access to the first generated cluster center elements
ClusterCenterPtr clusterCenter = pOutClustersCenters->getNodeColl<ClustersCenters::Coll>()[0];
const std::vector<ipReal64>& vRandomClusterElements = clusterCenter->getLeafColl<ClusterCenter::Elements>();
See also
KMeansComputeCentersLvl1
KMeansComputeCentersLvl2
KMeansComputeCentersLvl3

Function Documentation

◆ kMeansComputeCenters() [1/4]

IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pClassImg 
)

wrapper function for Compute clusters centroids given an input image and the image of classes

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ kMeansComputeCenters() [2/4]

IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pClassImg,
const ipsdk::image::ImageConstPtr pMaskImg 
)

wrapper function for Compute clusters centroids given an input image and the image of classes

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ kMeansComputeCenters() [3/4]

IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pClassImg,
const ipUInt32  nbClusters 
)

wrapper function for Compute clusters centroids given an input image and the image of classes

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ kMeansComputeCenters() [4/4]

IPSDKIPLCLASSIFICATION_API attr::ClustersCentersPtr ipsdk::imaproc::classif::kMeansComputeCenters ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pClassImg,
const ipsdk::image::ImageConstPtr pMaskImg,
const ipUInt32  nbClusters 
)

wrapper function for Compute clusters centroids given an input image and the image of classes

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure