IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Label Analysis 3dSee full documentation
MeasureSet = labelAnalysis3d (inGreyMsrImg3d,inLabelImg3d,inMeasureInfoSet3d)
MeasureSet = labelAnalysis3d (inGreyMsrImg3d,inLabelImg3d,inOptSurfaceExtractionSettings,inMeasureInfoSet3d)

Detailed Description

Connected component 3d analysis and measurement algorithm.

This algorithm is a simple version of Shape Analysis 3d algorithm. It allows to process measurements and analysis using a label (connected components) image as input which will be proceeded to extract associated 3d shapes (see Label shape extraction 3d).

Note
Note that boundary approximation will only be computed on extracted shapes if input measure set requests it (ie if at least one mesure among measure set requests it, see Measure requirements). This can be a good way of optimization since boundary approximation can be sometimes computionally expensive in 3d case.

For more information on shape analysis and measurement framework, please refers to Shape Analysis and Measurement.

Here is an example of shape 3d measurement and analysis :

shapeAnalysis3d.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho
import PyIPSDK.IPSDKIPLShapeAnalysis as shapeanalysis

Code Example

# opening of input images
inGreyImg = PyIPSDK.loadTiffImageFile(inputGreyImgPath)
inBinImg = PyIPSDK.loadTiffImageFile(inputBinImgPath)
# connected components analysis of binary image
inLabelImg3d = advmorpho.connectedComponent3dImg(inBinImg)
# definition of proceeded measure
inMeasureInfoSet3d1 = PyIPSDK.createMeasureInfoSet3d();
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d1, "VolumeMinusHoles", "MeshVolume3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(True));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d1, "VolumeWithHoles", "MeshVolume3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(False));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d1, "AreaMinusHoles", "Area3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(True));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d1, "AreaWithHoles", "Area3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(False));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d1, "EquivalentRay", "EquivalentRayMsr");
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d1, "SumMsr");
# shape analysis computation
outMeasureSet1 = shapeanalysis.labelAnalysis3d(inGreyImg, inLabelImg3d, PyIPSDK.createSubSampledSurfaceExtractionSettings(0), inMeasureInfoSet3d1)
# save results to csv format
PyIPSDK.saveCsvMeasureFile(os.path.join(utTmpPath, "shape_analysis_results.csv"), outMeasureSet1)
# retrieve measure results
outVolumeMinusHolesMsr = outMeasureSet1.getMeasure("VolumeMinusHoles")
outVolumeWithHolesMsr = outMeasureSet1.getMeasure("VolumeWithHoles")
outAreaMinusHolesMsr = outMeasureSet1.getMeasure("AreaMinusHoles")
outAreaWithHolesMsr = outMeasureSet1.getMeasure("AreaWithHoles")
outEquivalentRayMsr = outMeasureSet1.getMeasure("EquivalentRay")
outSumMsr = outMeasureSet1.getMeasure("SumMsr")
# retrieve measure valus for area with holes measurement
outVolumeWithHolesValues = outVolumeWithHolesMsr.getMeasureResult().getColl(0)
print("First label volume with holes measurement equal " + str(outVolumeWithHolesValues[1]))
# define a second measure info set which do not implies boundary approximation of shapes
inMeasureInfoSet3d2 = PyIPSDK.createMeasureInfoSet3d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d2, "HistogramQuantileMsr", shapeanalysis.createHistogramQuantileMsrParamsBinWidth(1.0, 25.0))
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d2, "NbPixels3dMsr")
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d2, "MeanMsr")
# in this case area measure request only row intersections of shapes with image so it will
# be automatically computed (boundary approximation are not)
outMeasureSet2 = shapeanalysis.labelAnalysis3d(inGreyImg, inLabelImg3d, PyIPSDK.createSubSampledSurfaceExtractionSettings(0), inMeasureInfoSet3d2)
# retrieve associated results
outHistogramQuantileMsr = outMeasureSet2.getMeasure("HistogramQuantileMsr")
outNbPixels3dMsr = outMeasureSet2.getMeasure("NbPixels3dMsr")
outMeanMsr = outMeasureSet2.getMeasure("MeanMsr")

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLShapeAnalysis/Processor/LabelAnalysis3d/LabelAnalysis3d.h>

Code Example

// opening grey level input image
ImagePtr pInGreyImg3d = loadTiffImageFile(inputGreyImgPath, eTiffDirectoryMode::eTDM_Volume);
// opening binary input image
ImagePtr pInBinImg3d = loadTiffImageFile(inputBinImgPath, eTiffDirectoryMode::eTDM_Volume);
// connected components analysis
ImagePtr pInLabelImg3d = connectedComponent3dImg(pInBinImg3d);
// define a measure info set
MeasureInfoSetPtr pMeasureInfoSet1 = MeasureInfoSet::create3dInstance();
createMeasureInfo(pMeasureInfoSet1, "VolumeMinusHoles", "MeshVolume3dMsr", createHolesBasicPolicyMsrParams(true));
createMeasureInfo(pMeasureInfoSet1, "VolumeWithHoles", "MeshVolume3dMsr", createHolesBasicPolicyMsrParams(false));
createMeasureInfo(pMeasureInfoSet1, "EquivalentRay", "EquivalentRayMsr");
createMeasureInfo(pMeasureInfoSet1, "SumMsr");
// compute measure on extracted data
// in this case area measure request boundary approximation of shapes so it will
// be automatically computed
MeasureSetPtr pOutMeasureSet1 = labelAnalysis3d(pInGreyImg3d, pInLabelImg3d, pMeasureInfoSet1);
// complete csv dump of results
saveCsvMeasureFile(csvOutputPath, *pOutMeasureSet1);
// retrieve associated results
const MeasureConstPtr& pAreaMinusHolesOutMsr = pOutMeasureSet1->getMeasure("VolumeMinusHoles");
const MeasureConstPtr& pAreaWithHolesOutMsr = pOutMeasureSet1->getMeasure("VolumeWithHoles");
const MeasureConstPtr& pEquivalentRayOutMsr = pOutMeasureSet1->getMeasure("EquivalentRay");
const MeasureConstPtr& pSumOutMsr = pOutMeasureSet1->getMeasure("SumMsr");
// define a second measure info set which do not implies boundary approximation of shapes
MeasureInfoSetPtr pMeasureInfoSet2 = MeasureInfoSet::create3dInstance();
createMeasureInfo(pMeasureInfoSet2, "HistogramQuantileMsr", createHistogramQuantileMsrParamsBinWidth(1.0, 25.0));
createMeasureInfo(pMeasureInfoSet2, "NbPixels3dMsr");
createMeasureInfo(pMeasureInfoSet2, "MeanMsr");
// compute measure on extracted data
// in this case area measure request only row intersections of shapes with image so it will
// be automatically computed (boundary approximation are not)
MeasureSetPtr pOutMeasureSet2 = labelAnalysis3d(pInGreyImg3d, pInLabelImg3d, createSubSampledSurfaceExtractionSettings(0), pMeasureInfoSet2);
// retrieve associated results
const MeasureConstPtr& pHistogramQuantileOutMsr = pOutMeasureSet2->getMeasure("HistogramQuantileMsr");
const MeasureConstPtr& pNbPixels3dOutMsr = pOutMeasureSet2->getMeasure("NbPixels3dMsr");
const MeasureConstPtr& pMeanOutMsr = pOutMeasureSet2->getMeasure("MeanMsr");