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

Binary area open; remove small objects

Syntax

Description

BW2 = bwareaopen(BW,P) removes from a binary image all connected components (objects) that have fewer than P pixels, producing another binary image, BW2. The default connectivity is 8 for two dimensions, 26 for three dimensions, and conndef(ndims(BW),'maximal') for higher dimensions.

BW2 = bwareaopen(BW,P,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 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

BW can be a logical or numeric array of any dimension, and it must be nonsparse. The return value BW2 is of class logical.

Algorithm

The basic steps are

  1. Determine the connected components.
  2. Compute the area of each component.
  3. Remove small objects.

Example

Read in the image and display it.

Remove all objects smaller than 50 pixels. Note the missing letters.

See Also

bwlabel, bwlabeln, conndef, regionprops


Previous page  bwarea bwboundaries Next page

© 1994-2005 The MathWorks, Inc.