modefilt
Description
performs
mode filtering on the 2-D image or 3-D volume B
= modefilt(A
)A
. Each output pixel in
B
contains the mode (most frequently occurring value) in the
neighborhood around the corresponding pixel in A
.
modefilt
pads A
by mirroring border
elements.
Mode filtering can be useful for processing categorical data, where other types of filtering, such as median filtering, are not available.
Examples
Input Arguments
Output Arguments
Tips
When the neighborhood has more than one pixel in a tie for the mode value, the function uses the following tie-breaking algorithm:
If the center pixel is one of the mode values in the tie, the function uses this value.
If the center pixel is not one of the mode values in the tie, the function uses the mode with the smallest numeric value.
For categorical input, the function chooses the first category (among the categories tied for mode) that appears in the list returned by
categories(A)
.
modefilt
treats RGB images as 3-D volumes. To do channel-wise filtering of an RGB image, specifyfiltSize
as[3 3 1]
, as in this code:b = modefilt(a,[3 3 1]);
.