machinevisiontoolbox.Image.thin

Image.thin(**kwargs)

Morphological skeletonization

Parameters:

kwargs – options passed to hitormiss

Returns:

Image

Return type:

Image instance

Return the thinned version (skeleton) of the binary image as another binary image. Any non-zero region is replaced by a network of single-pixel wide lines.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.String('000000|011110|011110|000000')
>>> img.print()
 0 0 0 0 0 0
 0 1 1 1 1 0
 0 1 1 1 1 0
 0 0 0 0 0 0
>>> img.thin().print()
 0 0 0 0 0 0
 0 1 0 0 1 0
 0 0 1 1 0 0
 0 0 0 0 0 0
>>> img = Image.Read("shark2.png")
>>> skeleton = img.thin()
References:
  • Robotics, Vision & Control for Python, Section 11.6.3, P. Corke, Springer 2023.

Seealso:

thin_animate hitormiss endpoint triplepoint