image = | skeleton2dImg (inBinImg) |
image = | skeleton2dImg (inBinImg,skeletonAlgoType) |
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 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.
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] :
[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.