IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Shape Analysis 3dSee full documentation
typedef ShapeAnalysisOptParams< ipsdk::shape::segmentation::Shape3dColl > ipsdk::imaproc::shape::analysis::ShapeAnalysis3dOptParams
typedef ShapeAnalysisOptParams< ipsdk::shape::segmentation::PlanIndexedShape3dColl > ipsdk::imaproc::shape::analysis::ShapeAnalysis3dPIOptParams
MeasureSet = shapeAnalysis3d (inOptGreyMsrImg3d1,inLabelsShape3d,inMeasureInfoSet3d)
MeasureSet = shapeAnalysis3d (inMeasureInfoSet3d,inLabelsShape3d,shapeAnalysis3dOptParams)

Detailed Description

Shape 3d analysis and measurement algorithm.

This algorithm allows to process measurements and analysis on shape 3d connected components.

User should first extract surface on a connected component label image (see Label shape extraction 3d).

Shape 3d measurements and analysis can be decomposed in three main groups :

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.IPSDKIPLShapeSegmentation as shapesegmentation
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)
# label contour extraction computation
inShape3dColl = shapesegmentation.labelShapeExtraction3d(inLabelImg3d, PyIPSDK.createSubSampledSurfaceExtractionSettings(0))
# definition of proceeded measure
inMeasureInfoSet3d = PyIPSDK.createMeasureInfoSet3d();
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "VolumeMinusHoles", "MeshVolume3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(True));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "VolumeWithHoles", "MeshVolume3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(False));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "AreaMinusHoles", "Area3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(True));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "AreaWithHoles", "Area3dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(False));
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "EquivalentRay", "EquivalentRayMsr");
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "SumMsr");
# shape analysis computation
outMeasureSet = shapeanalysis.shapeAnalysis3d(inGreyImg, inShape3dColl, inMeasureInfoSet3d)
# save results to csv format
PyIPSDK.saveCsvMeasureFile(os.path.join(utTmpPath, "shape_analysis_results.csv"), outMeasureSet)
# retrieve measure results
outVolumeMinusHolesMsr = outMeasureSet.getMeasure("VolumeMinusHoles")
outVolumeWithHolesMsr = outMeasureSet.getMeasure("VolumeWithHoles")
outAreaMinusHolesMsr = outMeasureSet.getMeasure("AreaMinusHoles")
outAreaWithHolesMsr = outMeasureSet.getMeasure("AreaWithHoles")
outEquivalentRayMsr = outMeasureSet.getMeasure("EquivalentRay")
outSumMsr = outMeasureSet.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]))

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLShapeAnalysis/Processor/ShapeAnalysis3d/ShapeAnalysis3d.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);
// extract contours from connected component (label) image
Shape3dCollPtr pShape3dColl = labelShapeExtraction3d(pInLabelImg3d);
// define a measure info set
MeasureInfoSetPtr pMeasureInfoSet = MeasureInfoSet::create3dInstance();
createMeasureInfo(pMeasureInfoSet, "VolumeMinusHoles", "Volume3dMsr", createHolesBasicPolicyMsrParams(true));
createMeasureInfo(pMeasureInfoSet, "VolumeWithHoles", "Volume3dMsr", createHolesBasicPolicyMsrParams(false));
createMeasureInfo(pMeasureInfoSet, "EquivalentRay", "EquivalentRayMsr");
createMeasureInfo(pMeasureInfoSet, "SumMsr");
// compute measure on extracted data
MeasureSetPtr pOutMeasureSet = shapeAnalysis3d(pInGreyImg3d, pShape3dColl, pMeasureInfoSet);
// complete csv dump of results
saveCsvMeasureFile(csvOutputPath, *pOutMeasureSet);
// retrieve associated results
const MeasureConstPtr& pAreaMinusHolesOutMsr = pOutMeasureSet->getMeasure("VolumeMinusHoles");
const MeasureConstPtr& pAreaWithHolesOutMsr = pOutMeasureSet->getMeasure("VolumeWithHoles");
const MeasureConstPtr& pEquivalentRayOutMsr = pOutMeasureSet->getMeasure("EquivalentRay");
const MeasureConstPtr& pSumOutMsr = pOutMeasureSet->getMeasure("SumMsr");