You are here : matlabImage Processingbwperim

bwperim() - Image Processing

BW2 = bwperim(BW) returns
a binary image that contains only the perimeter pixels of objects
in the input image BW. A pixel is part of the
perimeter if it is nonzero and it is connected to at least one zero-valued
pixel. The default connectivity is 4 for two dimensions, 6 for three
dimensions, and conndef(ndims(BW), 'minimal') for
higher dimensions. If you do not specify a return value, bwperim displays
the result in a figure window.BW2 = bwperim(BW,conn) where conn specifies
the desired connectivity.Code Generation support:
Yes.MATLAB Function Block support:
Yes.


Syntax

BW2 = bwperim(BW) exampleBW2 = bwperim(BW,conn)


Example

Find Perimeter of Objects in Binary ImageOpen This Example
Read binary image into workspace.BW = imread('circles.png');
Calculate the perimeters of objects in the image.BW2 = bwperim(BW,8);
Display the original image and the perimeters side-by-side.imshowpair(BW,BW2,'montage')


Output / Return Value


Limitations


Alternatives / See Also


Reference