Doubles = | volumePercent3dMsr (inImg) |
Doubles = | volumePercent3dMsr (inImg,inMaskImg) |
Computes the ratio between the number of pivoxels and the total image size.
This algorithm computes the ratio between the 3D objects volumes and the total image volume. Let VolumePercent(i) be the result for the ith object, Volume(i) its volume and (sizeX, sizeY, sizeZ) the image size, the calculation can be expressed as follows:
In the case of binary images, the result contains the volume ratio for the background (voxels set to 0) at index 0 and the volume ratio for the foreground (voxels set to 1) at index 1.
In the case of label images, the result contains the volume ratio for the background (voxels set to 0) at index 0 and then the volume ratio for each label.
Here is an example of result for a label image:
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr
Code Example
result = glbmsr.volumePercent3dMsr(inImg)
print("Volume percent for the first shape is " + str(result.coll[1]))
planIndexedResult = glbmsr.multiSlice_volumePercent3dMsr(inImg_multiSlice)
resSlice1 = PyIPSDK.toPyDict(planIndexedResult)[(0, 0, 1)]
print("Volume percent for the second slice is " + str(resSlice1["Coll"]))
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLGlobalMeasure/Processor/VolumePercent3dMsr/VolumePercent3dMsr.h>
Code Example
const std::vector<ipReal64>& vResult = pResult->getLeafColl<Doubles::Coll>();
PlanIndexedDoublesPtr pResult_multiSlice = multiSlice_volumePercent3dMsr(pInImg_multiSlice);
const ipUInt64 t = 1;
const std::vector<ipReal64>& vResult_multiSlice = pResult_multiSlice->getValue(0, 0, t).getNode<Doubles::Coll>().getColl();