{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / morphology / _skeletonize / thin

function

skimage.morphology._skeletonize:thin

source: /dev/scikit-image/src/skimage/morphology/_skeletonize.py :256

Signature

def   thin ( image max_num_iter = None )

Summary

Perform morphological thinning of a binary image.

Parameters

image : binary (M, N) ndarray

The image to thin. If this input isn't already a binary image, it gets converted into one: In this case, zero values are considered background (False), nonzero values are considered foreground (True).

max_num_iter : int, number of iterations, optional

Regardless of the value of this parameter, the thinned image is returned immediately if an iteration produces no change. If this parameter is specified it thus sets an upper bound on the number of iterations performed.

Returns

out : ndarray of bool

Thinned image.

Notes

This algorithm [1] works by making multiple passes over the image, removing pixels matching a set of criteria designed to thin connected regions while preserving eight-connected components and 2 x 2 squares [2]. In each of the two sub-iterations the algorithm correlates the intermediate skeleton image with a neighborhood mask, then looks up each neighborhood in a lookup table indicating whether the central pixel should be deleted in that sub-iteration.

Examples

square = np.zeros((7, 7), dtype=bool)
square[1:-1, 2:-2] = 1
square[0, 1] =  1
square.view(np.uint8)
skel = thin(square)
skel.view(np.uint8)

See also

medial_axis
skeletonize

Aliases

  • skimage.morphology.thin