IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Count the number of objects in the image. More...

IPSDKIPLGLOBALMEASURE_API ipsdk::ipUInt64 ipsdk::imaproc::glbmsr::counting2dMsr (const ipsdk::image::ImageConstPtr &pInLabelImg)
 wrapper function for Count the number of objects in the image More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedIndexableUInt64Ptr ipsdk::imaproc::glbmsr::multiSlice_counting2dMsr (const ipsdk::image::ImageConstPtr &pInLabelImg)
 wrapper function for Count the number of objects in the image More...
 

Detailed Description

Count the number of objects in the image.

This algorithm simply computes the number of objects in the input label image. If an image with 3 dimensions or more is provided, the algorithms returns the number of objects for each slice of each dimension.

Here is an example of result :

counting2d.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InLabelImg [Input] label image for processing operation X
ipsdk::imaproc::attr::OutPIIndexableUInt64 [Output] Plan indexed collection of container allowing to create a plan index of a single UInt64 ipsdk::imaproc::fromImage (_pOutPIIndexableUInt64, _pInLabelImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchImagePlans (_pOutPIIndexableUInt64,_pInLabelImg,eImagePlansMatchPolicy::eIPMP_ZCT)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr

Code Example

# measurement for a single slice
result = glbmsr.counting2dMsr(inLabelImg)
# retrieve measurement results
print("The number of objects is " + str(result))
# measurement for a multi-slice case
planIndexedResult = glbmsr.multiSlice_counting2dMsr(inLabelImg_multiSlice)
# retrieve measurement results
resSlice = PyIPSDK.toPyDict(planIndexedResult)[(1, 0, 0)]
print("The number of objects in the second slice is " + str(resSlice["Value"]))

Example of C++ code :

Example informations

Associated library

IPSDKIPLGlobalMeasure

Header file

Code Example

// -------------------------------------------------------
// Case of monoslice calculation
const ipUInt64 count_monoSlice = counting2dMsr(pLabelImg);
// -------------------------------------------------------
// Case of multislice calculation
const PlanIndexedIndexableUInt64Ptr pPICounts = multiSlice_counting2dMsr(pLabelImg_multiSlice);
const ipUInt64 countAtSlice1 = pPICounts->getValue(1, 0, 0).getValue<IndexableUInt64::Value>();
See also
Counting2dMsrLvl1
Counting2dMsrLvl2

Function Documentation

◆ counting2dMsr()

IPSDKIPLGLOBALMEASURE_API ipsdk::ipUInt64 ipsdk::imaproc::glbmsr::counting2dMsr ( const ipsdk::image::ImageConstPtr pInLabelImg)

wrapper function for Count the number of objects in the image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_counting2dMsr()

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedIndexableUInt64Ptr ipsdk::imaproc::glbmsr::multiSlice_counting2dMsr ( const ipsdk::image::ImageConstPtr pInLabelImg)

wrapper function for Count the number of objects in the image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure