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.
The following commands display the “thinned” edges of a Sobel filtered image:
; Open a file for reading:
OPENR, 1, FILEPATH('people.dat', SUBDIR = ['examples','data'])
; Create a byte array in which to store the image:
A = BYTARR(192, 192, /NOZERO)
; Read first 192 by 192 image:
READU, 1, A
; Close the file:
; Display the image:
TV, A, 0
; Apply the Sobel filter, threshold the image at value 75, and
; display the thinned edges:
TVSCL, THIN(SOBEL(A) GT 75), 1
Returns the thinned, two-dimensional byte array.
The two-dimensional image (array) to be thinned.
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.
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.
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).
This page has no user notes yet. Be the first one!