{ } Raw JSON

bundles / skimage latest / 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.ndarray

An image containing the objects to be skeletonized. Zeros or False represent background, nonzero values or True are foreground.

Returns

skeleton : ndarray

A 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

medial_axis
skeletonize
thin

Aliases

  • skimage.morphology._skeletonize._skeletonize_zhang