Plot region boundaries
h = visboundaries(___)
visboundaries( draws boundaries of regions in the
BW on the current axes.
a 2D binary image where pixels that are logical
true belong to
the foreground region and pixels that are logical
constitute the background.
bwboundaries to find the boundary
pixel locations in the image.
visboundaries( draws region boundaries
B is a cell array
containing the boundary pixel locations of the regions, similar in structure to the
first output from
bwboundaries. Each cell contains a
Q-by-2 matrix, where Q is the number of
boundary pixels for the corresponding region. Each row of these
Q-by-2 matrices contains the row and column coordinates of a
region boundaries on the axes specified by
visboundaries(___, passes the
name-value pair arguments to specify additional properties of the boundaries.
Parameter names can be abbreviated.
returns a handle
h = visboundaries(___)
h, for the boundaries.
BW = imread('blobs.png');
B = bwboundaries(BW);
Display image and plot boundaries on image.
imshow(BW) hold on visboundaries(B)
Read image and display it.
I = imread('toyobjects.png'); imshow(I) hold on
Segment the image using the active contours (snakes) algorithm. First, specify the initial contour location close to the object that is to be segmented.
mask = false(size(I)); mask(50:150,40:170) = true;
Display the initial contour on the original image in blue.
Segment the image using the
'edge' method using 200 iterations.
bw = activecontour(I, mask, 200, 'edge');
Display the final contour on the original image in red.
visboundaries(bw,'Color','r'); title('Blue - Initial Contour, Red - Final Contour');
BW— Binary image
Binary image, specified as a logical array.
B— Boundary pixel locations
Boundary pixel locations, specified as a cell array of Q-by-2 matrices containing row and column coordinates, where Q is the number of boundary pixels for the corresponding region.
ax— Image on which to draw boundaries
Image on which to draw boundaries, specified as an axes object.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'Color'— Color of the boundary
[R G B]| short name | long name
Color of the boundary, specified as a MATLAB®
'LineStyle'— Style of boundary line
Line style of boundary edge, specified as the comma-separated pair
'LineStyle' and any line specifier in
the table below.
|Line Style||Description||Resulting Line|
|No line||No line|
'LineWidth'— Width of the line used for the boundary
Width of the line used for the boundary, specified as a numeric value. Specify this value in points, where one point = 1/72 inch.
'EnhanceVisibility'— Augment the drawn boundary with contrasting features
Augment the drawn boundary with contrasting features to improve
visibility on a varying background, specified as the logical flag