This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Find region boundaries of segmentation


mask = boundarymask(L)
mask = boundarymask(BW)
mask = boundarymask(___,conn)



mask = boundarymask(L) computes a mask that represents the region boundaries for the input label matrix L. The output, mask, is a logical image that is true at boundary locations and false at non-boundary locations.

mask = boundarymask(BW) computes the region boundaries for the input binary image BW.

mask = boundarymask(___,conn) computes the region boundaries using a connectivity specified by conn.


collapse all

Read image into the workspace.

A = imread('kobi.png');

Create a superpixel representation of the image, returned as a label matrix.

L = superpixels(A,100);

Create the rasterized grid of the regions in the label matrix.

mask = boundarymask(L);

Display the boundary mask binary image.


Input Arguments

collapse all

Input label matrix, specified as a finite, nonnegative, nonsparse, 2-D numeric or logical array.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

Input binary image, specified as a numeric or logical array the same size as L.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | logical

Connectivity, specified as the numeric scalar 4 or 8. For a given pixel P in the input image, the corresponding output mask(P) is true if any of the pixels in the 4-connected or 8-connected neighborhood of P have a value different than P.




4-connected neighborhood


8-connected neighborhood

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Output Arguments

collapse all

Rasterized grid of region boundaries, specified as a 2-D logical matrix the same size as the input image.

Extended Capabilities

Introduced in R2016a

Was this topic helpful?