Reduce all objects to lines in 2-D binary image or 3-D binary volume
B = bwskel(A)
B = bwskel(V)
B = bwskel(___,'MinBranchLength',N)
Read a 2-D grayscale image into the workspace. Display the image. Objects of interest are dark threads against a light background.
I = imread('threads.png'); imshow(I)
Skeletonization requires a binary image in which foreground pixels are
1 (white) and the background is
0 (black). To make the original image suitable for skeletonization, take the complement of the image so that the objects are light and the background is dark. Then, binarize the result.
Icomplement = imcomplement(I); BW = imbinarize(Icomplement); imshow(BW)
Perform skeletonization of the binary image using
out = bwskel(BW);
Display the skeleton over the original image by using the
labeloverlay function. The skeleton appears as a 1-pixel wide cyan line over the dark threads.
Prune small spurs that appear on the skeleton and view the result. One short branch is pruned from a thread near the center of the image.
out2 = bwskel(BW,'MinBranchLength',15); imshow(labeloverlay(I,out2,'Transparency',0))
Read a binary image into the workspace.
BW1 = imread('circbw.tif');
Skeletonize objects in the image using the
BW2 = bwskel(BW1);
View the original image and the skeletonized image side by side.
Load a volumetric data set into the workspace. The name of the data set is
spiralVol. Display the volume using
load spiralVol.mat; volshow(spiralVol);
spiralVol data set to a binary format which is required by the
spiralVolLogical = imbinarize(spiralVol);
Skeletonize the spiral shape in the data set. Display the skeletonized volume with
spiralVolSkel = bwskel(spiralVolLogical);
A— Binary image
Binary image, specified as a 2-D logical array.
V— 3-D binary volume
3-D binary volume, specified as a 3-D logical array.
N— Minimum branch length
0(default) | nonnegative integer
Minimum branch length, specified as a nonnegative integer.
bwskel prunes branches shorter than
N. By default,
bwskel does not
B— Skeletonized image or volume
Skeletonized image or volume, returned as a 2-D or 3-D logical array of the same size as the input image or volume.
skeletonize 2-D images, you might get different results using
bwmorph than when using
Because they use different algorithms, the
uses 4-connectivity with 2-D images;
bwskel assumes that foreground objects in the binary image
are white (logical
true). If your image has a white
background and black objects, then use the complement of your image as the input
bwskel. You can compute the complement using
bwskel function uses the medial axis transform.
 Ta-Chih Lee, Rangasami L. Kashyap and Chong-Nam Chu. Building skeleton models via 3-D medial surface/axis thinning algorithms. Computer Vision, Graphics, and Image Processing, 56(6):462-478, 1994.
 Kerschnitzki, M, Kollmannsberger, P, Burghammer, M. et al. Architecture of the osteocyte network correlates with bone material quality. Journal of Bone and Mineral Research, 28(8):1837-1845, 2013.