mask= boundarymask(L)computes a mask that represents the region boundaries for the input label matrixL. The output,mask, is a logical image that istrueat boundary locations andfalseat non-boundary locations.
mask= boundarymask(BW)computes the region boundaries for the input binary imageBW.
mask= boundarymask(___,conn)computes the region boundaries using a connectivity specified byconn.
Create a superpixel representation of the image, returned as a label matrix.
L = superpixels(I,100);
Display the label matrix.
imshow(label2rgb(L))
Find the region boundaries of the label matrix.
mask = boundarymask(L);
Display the boundary mask over the original image by using thelabeloverlayfunction. The region boundaries of the label matrix appear as 1-pixel wide cyan lines.
Label matrix, specified as a 2-D numeric matrix of nonnegative numbers or a 2-D logical matrix.
Data Types:single|double|int8|int16|int32|uint8|uint16|uint32|logical
BW—Binary image numeric matrix|logical matrix
Binary image, specified as a numeric or logical matrix of the same size asL.
Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|logical
conn—Pixel connectivity 8(default) |4
Pixel connectivity, specified as4or8.
Value
Meaning
Two-Dimensional Connectivities
4
Pixels are connected if their edges touch. The neighborhood of a pixel are the adjacent pixels in the horizontal or vertical direction.
Current pixel is shown in gray.
8
Pixels are connected if their edges or corners touch. The neighborhood of a pixel are the adjacent pixels in the horizontal, vertical, or diagonal direction.
Current pixel is shown in gray.
Data Types:single|double|int8|int16|int32|uint8|uint16|uint32
mask— Rasterized grid of region boundaries 2-D logical matrix
Rasterized grid of region boundaries, specified as a 2-D logical matrix of the same size as the input image. A pixel inmaskistruewhen the corresponding pixel in the input image with valuePhas a neighboring pixel with a different value thanP.
Data Types:logical
Extended Capabilities
C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
boundarymasksupports the generation of C code (requiresMATLAB®Coder™). Note that if you choose the genericMATLAB Host Computertarget platform,boundarymaskgenerates code that uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, seeTypes of Code Generation Support in Image Processing Toolbox.
When generating code, the input argumentconnmust be a compile-time constant.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.