Image Processing Toolbox User's Guide Previous page   Next Page
bwperim

Find perimeter pixels in binary image

Syntax

Description

BW2 = bwperim(BW1) returns a binary image containing only the perimeter pixels of objects in the input image BW1. 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.

BW2 = bwperim(BW1,CONN) specifies the desired connectivity. CONN can have any of the following scalar values.

Value
Meaning
Two-dimensional connectivities
4
4-connected neighborhood
8
8-connected neighborhood
Three-dimensional connectivities
6
6-connected neighborhood
18
18-connected neighborhood
26
26-connected neighborhood

Connectivity can also be defined in a more general way for any dimension by using for CONN a 3-by-3-by-...-by-3 matrix of 0's and 1's. The 1-valued elements define neighborhood locations relative to the center element of CONN. Note that CONN must be symmetric about its center element.

Class Support

BW1 must be logical or numeric, and it must be nonsparse. BW2 is of class logical.

Example

See Also

bwarea, bweuler, conndef, imfill


Previous page  bwpack bwselect Next page

© 1994-2005 The MathWorks, Inc.