IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Label shape extraction 2dSee full documentation
Shape2dColl = labelShapeExtraction2d (inLabelImg)
Shape2dColl = labelShapeExtraction2d (inLabelImg,inOptContourExtractionSettings)

Detailed Description

shape extraction from label 2d image algorithm

This algorithm allows to extract shapes from a label (Connected Component 2d) input 2d image. These contours are stored into a collection of shape 2d objets (ipsdk::geom::Shape2d) indexed by their label.

Each shape is define with respect to a neighborhood 2d policy and can be optionally simplified by a polygonal approximation algorithm.

Four options allow to control processing (See ContourExtractionSettings) :

In a standard case where input label image is obtained using IPSDK connected component 2d algorithm, a given label index will be associated to a single shape (used neighborhood 2d type should be the same for connected component 2d and for label shape extraction 2d operations).

In some other cases a given label index may be associated to several "unconnected" components. In this case a label index may be associated to several shapes.

Here is an example of a label shape extraction 2d operation applied to a label input image composed of a single connected component :

Here is an other example of a label shape extraction 2d operation applied to a label input image composed of a single connected component with a hole :

labelShapeExtraction2d3.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho
import PyIPSDK.IPSDKIPLShapeSegmentation as shapesegmentation

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# connected components analysis
inLabelImg2d = advmorpho.connectedComponent2dImg(inImg)
# label contour extraction computation
outShape2dColl = shapesegmentation.labelShapeExtraction2d(inLabelImg2d)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLShapeSegmentation/Processor/LabelShapeExtraction2d/LabelShapeExtraction2d.h>

Code Example

// opening input image
ImagePtr pInBinImg2d = loadTiffImageFile(inputBinImgPath);
// connected components analysis
ImagePtr pInLabelImg2d = connectedComponent2dImg(pInBinImg2d, pContourExtractionSettings->getValue<ContourExtractionSettings::Neighborhood2dType>());
// extract contours from connected component (label) image
Shape2dCollPtr pShape2dColl = labelShapeExtraction2d(pInLabelImg2d, pContourExtractionSettings);