IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Shape to label 2d imageSee full documentation
imageshapeToLabel2dImg (inLabelsShape2d)
imageshapeToLabel2dImg (inPILabelsShape2d)

Detailed Description

algorithm allowing to create a label 2d image from a collection of shape

This algorithm allows to re-create a label image (Connected Component 2d) from a shape 2d image. Shape intersection with image rows are set with respect to shape label.

Note
if some shape intersect, intersection pixels are set to highest label value.

Here is an example of a shape to label 2d image operation :

shapeToLabel2dImg.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,
PyIPSDK.eTiffDirectoryMode.eTDM_Volume,
PyIPSDK.eTiffBufferMode.eTBM_Binary)
# connected components analysis
inLabelImg2d = advmorpho.connectedComponent2dImg(inImg)
# label contour extraction computation
outShape2dColl = shapesegmentation.labelShapeExtraction2d(inLabelImg2d)
# write extracted shapes to output label image
outLabelImg = shapesegmentation.shapeToLabel2dImg(outShape2dColl);

Example of C++ code :

Example informations

Header file

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

Code Example

// opening input image
ImagePtr pInBinImg2d = loadTiffImageFile(inputBinImgPath,
eTiffDirectoryMode::eTDM_Volume,
eTiffBufferMode::eTBM_Binary);
// connected components analysis
ImagePtr pInLabelImg2d = connectedComponent2dImg(pInBinImg2d);
// extract contours from connected component (label) image
Shape2dCollPtr pShape2dColl = labelShapeExtraction2d(pInLabelImg2d);
// write extracted shapes to output label image
ImagePtr pOutLabelImg = shapeToLabel2dImg(pShape2dColl);