scalar = | counting2dMsr (inLabelImg) |
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 :
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr
Code Example
result = glbmsr.counting2dMsr(inLabelImg)
print("The number of objects is " + str(result))
planIndexedResult = glbmsr.multiSlice_counting2dMsr(inLabelImg_multiSlice)
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
Header file
#include <IPSDKIPL/IPSDKIPLGlobalMeasure/Processor/Counting2dMsr/Counting2dMsr.h>
Code Example
const ipUInt64 count_monoSlice = counting2dMsr(pLabelImg);
const PlanIndexedIndexableUInt64Ptr pPICounts = multiSlice_counting2dMsr(pLabelImg_multiSlice);
const ipUInt64 countAtSlice1 = pPICounts->getValue(1, 0, 0).getValue<IndexableUInt64::Value>();