IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

computes the 2d skeleton image from a binary image More...

IPSDKIPLBASICMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::morpho::skeleton2dImg (const image::ImageConstPtr &pInBinImg)
 wrapper function for computes the 2d skeleton image from a binary image More...
 
IPSDKIPLBASICMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::morpho::skeleton2dImg (const image::ImageConstPtr &pInBinImg, const attr::eSkeletonAlgoType &skeletonAlgoType)
 wrapper function for computes the 2d skeleton image from a binary image More...
 
IPSDKIPLBASICMORPHOLOGY_API void ipsdk::imaproc::morpho::skeleton2dImg (const image::ImageConstPtr &pInBinImg, const image::ImagePtr &pOutBinImg)
 wrapper function for computes the 2d skeleton image from a binary image More...
 
IPSDKIPLBASICMORPHOLOGY_API void ipsdk::imaproc::morpho::skeleton2dImg (const image::ImageConstPtr &pInBinImg, const attr::eSkeletonAlgoType &skeletonAlgoType, const image::ImagePtr &pOutBinImg)
 wrapper function for computes the 2d skeleton image from a binary image More...
 

Detailed Description

computes the 2d skeleton image from a binary image

The skeleton provides morphological and topological properties of an object. This function computes the image of skeletons from the objects present in the input binary image by iterative thinnings.

Two algorithms are available to compute the default or the smooth skeletons from the input binary image.

For the first approach, the objects are iteratively reduced by eliminating all pixels at the borders except the corners. This thinning is processed until each remaining pixel has only two 4-neighbours set to 1 in the ouput binary image. The last thinning steps involve reducing the neighbourhood to 8-connexity.

The second method used for this algorithm was proposed by Zhang and Suen [1], in which each pass is decomposed by 2 sub-iterations.

For a single passs, a pixel $ I[x, y] $ can be deleted if its 3x3 neighbouhood respects the conditions :

The algorithm is faster than the default approach and the output skeletons are smoother than the ones obtained by the default algorithm, with less branches. It is therefore more robust to border variations but can yield coarser approximations and missing information. The results are similar than the skeletonize function provided by the skimage python module with default parameters.

See also
https://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.skeletonize

Here is the result of the skeleton operation applied to a binary image. We can clearly notice the difference between the default algorithm (left) and the algorithm proposed by [1] :

skeleton2dImg.png

[1] Zhang, T. Y. and Suen, C. Y., "A fast parallel algorithm for thinning digital patterns", Communications of the ACM, March 1984, Volume 27, Number 3.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InBinImg [Input] binary image for processing operation X
ipsdk::imaproc::attr::InOptSkeletonAlgoType [Input Optional] Determine the skeleton calculation method X
ipsdk::imaproc::attr::OutWk1BinImg [Output] Temporary working image for algorithm ipsdk::imaproc::duplicateInOut (_pOutWk1BinImg, _pInBinImg)
ipsdk::imaproc::attr::OutBinImg [Output] binary image for processing operation ipsdk::imaproc::duplicateInOut (_pOutBinImg, _pInBinImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSizeAndType (_pInBinImg,_pOutBinImg) && 
ipsdk::imaproc::matchSizeAndType (_pInBinImg,_pOutWk1BinImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# boundary 2d image computation
outImg = morpho.skeleton2dImg(inImg)

Example of C++ code :

Example informations

Associated library

IPSDKIPLBasicMorphology

Header file

Code Example

// opening input image
ImagePtr pInBinImg = loadTiffImageFile(inputImgPath);
// compute skeletons on input image
ImagePtr pOutImg = skeleton2dImg(pInBinImg);
See also
Skeleton2dImgLvl1

Function Documentation

◆ skeleton2dImg() [1/4]

IPSDKIPLBASICMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::morpho::skeleton2dImg ( const image::ImageConstPtr pInBinImg)

wrapper function for computes the 2d skeleton image from a binary image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ skeleton2dImg() [2/4]

IPSDKIPLBASICMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::morpho::skeleton2dImg ( const image::ImageConstPtr pInBinImg,
const attr::eSkeletonAlgoType skeletonAlgoType 
)

wrapper function for computes the 2d skeleton image from a binary image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ skeleton2dImg() [3/4]

IPSDKIPLBASICMORPHOLOGY_API void ipsdk::imaproc::morpho::skeleton2dImg ( const image::ImageConstPtr pInBinImg,
const image::ImagePtr pOutBinImg 
)

wrapper function for computes the 2d skeleton image from a binary image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ skeleton2dImg() [4/4]

IPSDKIPLBASICMORPHOLOGY_API void ipsdk::imaproc::morpho::skeleton2dImg ( const image::ImageConstPtr pInBinImg,
const attr::eSkeletonAlgoType skeletonAlgoType,
const image::ImagePtr pOutBinImg 
)

wrapper function for computes the 2d skeleton image from a binary image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure