Also known as geodesic Voronoi, pixels are given the label of their closest seed, according to geodesic distance. The following GIF demonstrates the process. In this example, seeds with unique labels are placed at the wrist and the tip of each finger.
bwgrowregions
is particularly useful for centerline- or skeleton-based segmentation, by finding the skeleton of an image, segmenting the skeleton, using it to define seeds, and growing the regions to cover the entire area of the image. For example, in figure (a) below, the centerline of the colon has been segmented into semantic segments, which are then transferred to the volume. In figure (b), the centerline has instead been split into a number of segments with a preset length.
(a) | (b) |
---|---|
labels = bwgrowregions( I )
labels = bwgrowregions( I, distanceMetric )
[ labels, distanceTransform ] = bwgrowregions( __ )
Argument | Description |
---|---|
I |
Image defining the traversable pixels and seed locations, given as a 2D or 3D numeric array. Must contain at least 1 seed. Note:
|
distanceMetric |
(Optional) Which metric to use for calculating the distance transform. This therefore affects the precedence of labels for pixels with a path connected to more than one seed. Either:
|
Argument | Description |
---|---|
labels |
Label matrix of the segmented region of I , according to the traversable region, seed locations, and seed labels. Returned as a numeric array of the same size as I . Each pixel is given of the closest seed. Traversable regions without a connected path to any seed have a value of 0 . Untraversable regions have a value of NaN . To plot the output, first set all NaN values to 0 , i.e., labels(isnan(labels)) = 0 . |
distanceTransform |
Geodesic distances to the closest seed, returned as a numeric array of the same size as I . Seed locations have a value of 0 , while pixels which are not traversable or cannot be reached have a value of Inf . |
Please see examples.mlx or examples.pdf.
Created in 2022b. Compatible with MATLAB release 2019b and later. Compatible with all platforms.
Published under MIT License (see LICENSE.txt).
Please cite George Abrahams (GitHub, LinkedIn, Google Scholar).