bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / morphology / _skeletonize / _skeletonize_zhang
function
skimage.morphology._skeletonize:_skeletonize_zhang
source: /dev/scikit-image/src/skimage/morphology/_skeletonize.py :99
Signature
def _skeletonize_zhang ( image ) Summary
Return the skeleton of a 2D binary image.
Extended Summary
Thinning is used to reduce each connected component in a binary image to a single-pixel wide skeleton.
Parameters
image: numpy.ndarrayAn image containing the objects to be skeletonized. Zeros or
Falserepresent background, nonzero values orTrueare foreground.
Returns
skeleton: ndarrayA matrix containing the thinned image.
Notes
The algorithm [Zha84] works by making successive passes of the image, removing pixels on object borders. This continues until no more pixels can be removed. The image is correlated with a mask that assigns each pixel a number in the range [0...255] corresponding to each possible pattern of its 8 neighboring pixels. A look up table is then used to assign the pixels a value of 0, 1, 2 or 3, which are selectively removed during the iterations.
Note that this algorithm will give different results than a medial axis transform, which is also often referred to as "skeletonization".
Examples
X, Y = np.ogrid[0:9, 0:9] ellipse = (1./3 * (X - 4)**2 + (Y - 4)**2 < 3**2).astype(bool) ellipse.view(np.uint8)✓
skel = skeletonize(ellipse) skel.view(np.uint8)⚠
See also
Aliases
-
skimage.morphology._skeletonize._skeletonize_zhang