IPSDK 4.2
IPSDK : Image Processing Software Development Kit
Connected Component 2d
image = connectedComponent2dImg (inBinLabImg)
image = connectedComponent2dImg (inBinLabImg,inOptNeighborhood2d)
scalar = connectedComponent2dImg (inBinLabImg,inOptNeighborhood2d,outLabelImg)

Detailed Description

Connected component image 2d labeling algorithm.

Connected component labeling algorithm allows to uniquely labeled subsets of connected components with respect to a given neighborhood policy.

Output labels start with 1 and are consecutive with respect to scanning order (from lower x then y to higher).

For more informations on used neighborhood 2d types report to 2d neighborhood models.

Resulting image buffer type must be one of the following :

Here is an example of connected component extraction operation applied to a binary input image (with 8 connexity neighborhood type) :

connectedComponent2dImg8Connexity.png

Here is an example of connected component extraction operation applied to a binary input image (with 4 connexity neighborhood type) :

connectedComponent2dImg4Connexity.png

The algorithm also allows to relabel a label image. This way all connected component will be assigned to a unique label.

Here is an example of relabel of a label image using the connected component algorithm in 2d case :

connectedComponent2dImgRelabel.png
Note
Last wrapper function returns number of extracted connected components (unique labels).
If number of extracted connected components exceed output image data type capacity (case of a number of connected components greater than 65535 and an output image associated to a ipsdk::image::eImageBufferType::eIBT_Label16 data type), output image data type is automatically upgraded to ipsdk::image::eImageBufferType::eIBT_Label32.
See also
http://en.wikipedia.org/wiki/Connected-component_labeling

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# connected components 2d computation
outImg = advmorpho.connectedComponent2dImg(inImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/ConnectedComponent2dImg/ConnectedComponent2dImg.h>

Code Example

// opening input image
ImagePtr pInBinImg = loadTiffImageFile(inputImgPath);
// compute connected component label image associated to input image
ImagePtr pOutLabelImg = connectedComponent2dImg(pInBinImg);