bwpropfilt() - Image Processing
BW2 = bwpropfilt(BW,attrib,range) extracts
all connected components (objects) from a binary image BW that
meet the criteria specified by attrib and range.
attrib is a text string that identifies a particular
property of the objects, such as their area. range is
a 1-by-2 row vector that specifies the range of values (low and high)
of the property. bwpropfilt returns a binary image BW2 containing
only those objects that meet the criteria.exampleBW2 = bwpropfilt(BW,attrib,n) sorts
the objects based on the value of the specified property, attrib,
returning a binary image that contains only the top n largest
objects. In the event of a tie for n-th place, bwpropfilt keeps
only the first n objects in BW2.BW2 = bwpropfilt(BW,attrib,n,keep) sorts
the objects based on attrib values, keeping the n largest
values if keep is 'largest' (the
default) and the n smallest if keep is 'smallest'.BW2 = bwpropfilt(BW,I,attrib,___) sorts
objects based on the intensity values in the grayscale image I and
the property attrib.BW2 = bwpropfilt(BW,___, conn) specifies
the desired connectivity. Connectivity can be either 4, 8, or a 3-by-3
matrix of 0s and 1. The 1-valued elements define neighborhood locations
relative to the center element of conn and conn must
be symmetric about its center element.
Syntax
BW2 = bwpropfilt(BW,attrib,range) exampleBW2 = bwpropfilt(BW,attrib,n) exampleBW2 = bwpropfilt(BW,attrib,n,keep)BW2 = bwpropfilt(BW,I,attrib,___)BW2 = bwpropfilt(BW,___, conn)
Example
Find Regions Without HolesOpen This Example
Read image and display it.BW = imread('text.png');
figure
imshow(BW)
title('Original Image')
Use filtering to create a second image that contains only those regions in the original image that do not have holes. For these regions, the Euler number property is equal to 1. Display filtered image.BW2 = bwpropfilt(BW,'EulerNumber',[1 1]);
figure
imshow(BW2)
title('Regions with Euler Number == 1')
Find Which Ten Objects Have Largest PerimetersOpen This Example
Read image.BW = imread('text.png');
Find the ten objects in the image with the largest perimeters and display filtered image.BW2 = bwpropfilt(BW,'perimeter',10);
figure;
imshow(BW2)
title('Objects with the Largest Perimeters')
Related ExamplesFilter Images on Region Properties Using Image Region Analyzer
App
Output / Return Value
Limitations
Alternatives / See Also
Reference