Functions > Image Processing > Morphological Processing > Thinning and Skeletonizing
  
Thinning and Skeletonizing
thin(M, b)—Returns the thinned version of matrix M binarized with threshold b.
skeleton(B,[b])—Returns binary matrix B eroded to its innermost level.
These functions transform objects in an image into a set of lines that run roughly down the center of each object.
The thin and skeleton functions binarize the image first, then thin or skeletonize. This is useful for image analysis in pattern recognition, for example, for optical character recognition (OCR).
Thinning and skeletonization are extreme forms of morphological processing, and are used when only the fundamental shape of an object on the image is of interest. Unlike the thinning operation, skeleton retains the size of the input object. The end points of the skeleton extend all the way to the edges of the input object.
Thinning transforms objects on a binary image to a set of simple digital lines (or arcs), which lie roughly along the objects' medial axis (center line). The structure obtained is not influenced by small inflections on the image object. The algorithm recursively deletes simple border points that have more than one neighbor. With this algorithm, the end points of thin arcs are not deleted.
* 
If the optional argument b is not supplied, then the skeleton function performs simple skeletonization - erosion of the edges of a binarized image until there is nothing left but the central lines. The skeleton function works best on a white image against a black background.
If the optional argument b is not supplied, then the skeleton function uses a more advanced skeletonization algorithm, where the skeleton of an object is defined as the set of points whose distance to the nearest boundary is a local maximum. It is possible to recover the original binary image given its skeleton and the distance of each skeleton point to its contour by taking the union of the circular neighborhoods centered on the skeleton points with radii equal to the associated contour distance. The skeleton, in this case, is a regenerative representation of an image object.
Arguments
M is a grayscale image matrix.
B is a binarized image matrix.
b is a real number representing the binarization intensity threshold value.
b is optional for the skeleton function.