The THIN function returns the “skeleton” of a bi-level image. The skeleton of an object in an image is a set of lines that reflect the shape of the object. The set of skeletal pixels can be considered to be the medial axis of the object.
On input, the bi-level image is a rectangular array in which pixels that compose the object have a nonzero value. All other pixels are zero. The result is a byte type image in which skeletal pixels are set to 2 and all other pixels are zero.
Examples
The following commands display the “thinned” edges of a Sobel filtered image:
OPENR, 1, FILEPATH('people.dat', SUBDIR = ['examples','data'])
A = BYTARR(192, 192, /NOZERO)
READU, 1, A
CLOSE, 1
TV, A, 0
TVSCL, THIN(SOBEL(A) GT 75), 1
Syntax
Result = THIN( Image [, /NEIGHBOR_COUNT] [, /PRUNE] )
Return Value
Returns the thinned, two-dimensional byte array.
Arguments
Image
The two-dimensional image (array) to be thinned.
Keywords
NEIGHBOR_COUNT
Set this keyword to select an alternate form of output. In this form, output pixel values count the number of neighbors an individual skeletal pixel has (including itself). For example, a pixel that is part of a line will have the value 3 (two neighbors and itself). Terminal pixels will have the value 2, while isolated pixels have the value 1.
PRUNE
If the PRUNE keyword is set, pixels with single neighbors are removed iteratively until only pixels with 2 or more neighbors exist. This effectively removes (or “prunes”) skeleton branches, leaving only closed paths.
Version History
Resources and References
For a much more extensive discussion of skeletons and thinning algorithms, see Algorithms for Graphics and Image Processing, Theo Pavlidis, Computer Science Press, 1982. The THIN function is adapted from Algorithm 9.1 (the classical thinning algorithm).
See Also
ROBERTS, SOBEL