Reduce all objects to lines in 2-D binary image or 3-D binary volume
reduces all objects in the 2-D binary image
B = bwskel(
A to 1-pixel wide
curved lines, without changing the essential structure of the image. This process,
called skeletonization, extracts the centerline while
preserving the topology and Euler number (also known as the Euler characteristic) of
Skeletonize 2-D Grayscale Image
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 blue 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))
Skeletonize Binary Image
Read a binary image into the workspace.
BW1 = imread('circbw.tif');
Skeletonize objects in the image by using the
BW2 = bwskel(BW1);
View the original image and the skeletonized image side by side.
Skeletonize 3-D Volume
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); volshow(spiralVolSkel);
A — Binary image
2-D logical matrix
Binary image, specified as a 2-D logical matrix.
V — 3-D binary volume
3-D logical array
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
2-D logical matrix | 3-D logical array
Skeletonized image or volume, returned as a 2-D logical matrix or 3-D logical array of the same size as the input image or volume.
bwmorphcan skeletonize 2-D images, you can get different results using
bwmorphthan when using
bwskel. Because they use different algorithms, the
bwskelfunction uses 4-connectivity with 2-D images;
bwskelassumes 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 to
bwskel. You can compute the complement by using
bwskelfunction 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.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version HistoryIntroduced in R2018a
R2022b: Support for thread-based environments
bwskel now supports thread-based