IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Connected component 2d analysis and measurement algorithm. More...

IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::MeasureSetPtr ipsdk::imaproc::shape::analysis::labelAnalysis2d (const ipsdk::image::ImageConstPtr &pInGreyMsrImg, const ipsdk::image::ImageConstPtr &pInLabelImg, const ipsdk::shape::analysis::MeasureInfoSetConstPtr &pInMeasureInfoSet2d)
 wrapper function for Connected component 2d analysis and measurement algorithm More...
 
IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::MeasureSetPtr ipsdk::imaproc::shape::analysis::labelAnalysis2d (const ipsdk::image::ImageConstPtr &pInGreyMsrImg, const ipsdk::image::ImageConstPtr &pInLabelImg, const ipsdk::imaproc::attr::ContourExtractionSettingsConstPtr &pInOptContourExtractionSettings, const ipsdk::shape::analysis::MeasureInfoSetConstPtr &pInMeasureInfoSet2d)
 wrapper function for Connected component 2d analysis and measurement algorithm More...
 
IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::PlanIndexedMeasureSetPtr ipsdk::imaproc::shape::analysis::multiSlice_labelAnalysis2d (const ipsdk::image::ImageConstPtr &pInGreyMsrImg, const ipsdk::image::ImageConstPtr &pInLabelImg, const ipsdk::shape::analysis::MeasureInfoSetConstPtr &pInMeasureInfoSet2d)
 wrapper function for Connected component 2d analysis and measurement algorithm More...
 
IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::PlanIndexedMeasureSetPtr ipsdk::imaproc::shape::analysis::multiSlice_labelAnalysis2d (const ipsdk::image::ImageConstPtr &pInGreyMsrImg, const ipsdk::image::ImageConstPtr &pInLabelImg, const ipsdk::imaproc::attr::ContourExtractionSettingsConstPtr &pInOptContourExtractionSettings, const ipsdk::shape::analysis::MeasureInfoSetConstPtr &pInMeasureInfoSet2d)
 wrapper function for Connected component 2d analysis and measurement algorithm More...
 

Detailed Description

Connected component 2d analysis and measurement algorithm.

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

Note
Note that boundary approximation will only be computed on extracted shapes if the input measure set requests it (ie if at least one mesure among measure set requests it, see Measure requirements).

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

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

shapeAnalysis2d.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InGreyMsrImg [Input] grey image used for intensity measurements X
ipsdk::imaproc::attr::InLabelImg [Input] label image for processing operation X
ipsdk::imaproc::attr::InOptContourExtractionSettings [Input Optional] Settings used for contours extraction X
ipsdk::imaproc::attr::InMeasureInfoSet2d [Input] shape analysis 2d measure information set X
ipsdk::imaproc::attr::OutPIMeasureSet [Output] Plan indexed collection of shape analysis measure set fromImageButColor (_pOutPIMeasureSet, _pInGreyMsrImg, boost::function<OutPIMeasureSet::PlanStorageType()>(boost::bind(&ipsdk::imaproc::createMeasureSetFromInfo,_pInMeasureInfoSet2d)))

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (ipsdk::imaproc::eMatchImageSizeType::eMIST_XYZT,_pInGreyMsrImg,_pInLabelImg) && 
ipsdk::imaproc::matchImagePlansButColor (_pOutPIMeasureSet,_pInGreyMsrImg) && 
matchLabelAnalysis (_pInMeasureInfoSet2d)

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
inLabelImg2d = advmorpho.connectedComponent2dImg(inBinImg)
# definition of proceeded measure
inMeasureInfoSet2d1 = PyIPSDK.createMeasureInfoSet2d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d1, "AreaMinusHoles", "Area2dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(True))
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d1, "AreaWithHoles", "Area2dMsr", shapeanalysis.createHolesBasicPolicyMsrParams(False))
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d1, "EquivalentRay", "EquivalentRayMsr")
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d1, "SumMsr")
# shape analysis computation
# in this case area measure request boundary approximation of shapes so it will
# be automatically computed
outMeasureSet1 = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d1)
# save results to csv format
PyIPSDK.saveCsvMeasureFile(os.path.join(utTmpPath, "shape_analysis_results.csv"), outMeasureSet1)
# retrieve measure results
outAreaMinusHolesMsr = outMeasureSet1.getMeasure("AreaMinusHoles")
outAreaWithHolesMsr = outMeasureSet1.getMeasure("AreaWithHoles")
outEquivalentRayMsr = outMeasureSet1.getMeasure("EquivalentRay")
outSumMsr = outMeasureSet1.getMeasure("SumMsr")
# retrieve measure valus for area with holes measurement
outAreaWithHolesValues = outAreaWithHolesMsr.getMeasureResult().getColl(0)
print("First label area with holes measurement equal " + str(outAreaWithHolesValues[1]))
# define a second measure info set which do not implies boundary approximation of shapes
inMeasureInfoSet2d2 = PyIPSDK.createMeasureInfoSet2d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d2, "HistogramQuantileMsr", shapeanalysis.createHistogramQuantileMsrParamsBinWidth(1.0, 25.0))
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d2, "NbPixels2dMsr")
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d2, "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.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d2)
# retrieve associated results
outHistogramQuantileMsr = outMeasureSet2.getMeasure("HistogramQuantileMsr")
outNbPixels2dMsr = outMeasureSet2.getMeasure("NbPixels2dMsr")
outMeanMsr = outMeasureSet2.getMeasure("MeanMsr")

Example of C++ code :

Example informations

Associated library

IPSDKIPLShapeAnalysis

Header file

Code Example

// opening grey level input image
ImagePtr pInGreyImg2d = loadTiffImageFile(inputGreyImgPath);
// opening binary input image
ImagePtr pInBinImg2d = loadTiffImageFile(inputBinImgPath);
// connected components analysis
ImagePtr pInLabelImg2d = connectedComponent2dImg(pInBinImg2d);
// define a measure info set
MeasureInfoSetPtr pMeasureInfoSet1 = MeasureInfoSet::create2dInstance();
createMeasureInfo(pMeasureInfoSet1, "AreaMinusHoles", "Area2dMsr", createHolesBasicPolicyMsrParams(true));
createMeasureInfo(pMeasureInfoSet1, "AreaWithHoles", "Area2dMsr", 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 = labelAnalysis2d(pInGreyImg2d, pInLabelImg2d, pMeasureInfoSet1);
// complete csv dump of results
saveCsvMeasureFile(csvOutputPath, *pOutMeasureSet1);
// retrieve associated results
const MeasureConstPtr& pAreaMinusHolesOutMsr = pOutMeasureSet1->getMeasure("AreaMinusHoles");
const MeasureConstPtr& pAreaWithHolesOutMsr = pOutMeasureSet1->getMeasure("AreaWithHoles");
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::create2dInstance();
createMeasureInfo(pMeasureInfoSet2, "HistogramQuantileMsr", createHistogramQuantileMsrParamsBinWidth(1.0, 25.0));
createMeasureInfo(pMeasureInfoSet2, "NbPixels2dMsr");
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 = labelAnalysis2d(pInGreyImg2d, pInLabelImg2d, pMeasureInfoSet2);
// retrieve associated results
const MeasureConstPtr& pHistogramQuantileOutMsr = pOutMeasureSet2->getMeasure("HistogramQuantileMsr");
const MeasureConstPtr& pNbPixels2dOutMsr = pOutMeasureSet2->getMeasure("NbPixels2dMsr");
const MeasureConstPtr& pMeanOutMsr = pOutMeasureSet2->getMeasure("MeanMsr");
See also
LabelAnalysis2dLvl1

Function Documentation

◆ labelAnalysis2d() [1/2]

IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::MeasureSetPtr ipsdk::imaproc::shape::analysis::labelAnalysis2d ( const ipsdk::image::ImageConstPtr pInGreyMsrImg,
const ipsdk::image::ImageConstPtr pInLabelImg,
const ipsdk::shape::analysis::MeasureInfoSetConstPtr pInMeasureInfoSet2d 
)

wrapper function for Connected component 2d analysis and measurement algorithm

Note
This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_labelAnalysis2d() [1/2]

IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::PlanIndexedMeasureSetPtr ipsdk::imaproc::shape::analysis::multiSlice_labelAnalysis2d ( const ipsdk::image::ImageConstPtr pInGreyMsrImg,
const ipsdk::image::ImageConstPtr pInLabelImg,
const ipsdk::shape::analysis::MeasureInfoSetConstPtr pInMeasureInfoSet2d 
)

wrapper function for Connected component 2d analysis and measurement algorithm

Note
This wrapper can be used with multi slice input images
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ labelAnalysis2d() [2/2]

IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::MeasureSetPtr ipsdk::imaproc::shape::analysis::labelAnalysis2d ( const ipsdk::image::ImageConstPtr pInGreyMsrImg,
const ipsdk::image::ImageConstPtr pInLabelImg,
const ipsdk::imaproc::attr::ContourExtractionSettingsConstPtr pInOptContourExtractionSettings,
const ipsdk::shape::analysis::MeasureInfoSetConstPtr pInMeasureInfoSet2d 
)

wrapper function for Connected component 2d analysis and measurement algorithm

Note
This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_labelAnalysis2d() [2/2]

IPSDKIPLSHAPEANALYSIS_API ipsdk::shape::analysis::PlanIndexedMeasureSetPtr ipsdk::imaproc::shape::analysis::multiSlice_labelAnalysis2d ( const ipsdk::image::ImageConstPtr pInGreyMsrImg,
const ipsdk::image::ImageConstPtr pInLabelImg,
const ipsdk::imaproc::attr::ContourExtractionSettingsConstPtr pInOptContourExtractionSettings,
const ipsdk::shape::analysis::MeasureInfoSetConstPtr pInMeasureInfoSet2d 
)

wrapper function for Connected component 2d analysis and measurement algorithm

Note
This wrapper can be used with multi slice input images
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure