filters data by replacing every value by the mean value in its range-r neighborhood.


uses ri for filtering the ^(th)dimension in data.


  • CommonestFilter, also known as majority filter, is used to filter data by returning the commonest local value, where the extent of the effect is dependent on the value of r.
  • The function applied to each range-r neighborhood is Commonest.
  • The data can be any of the following:
  • listarbitrary-rank numerical array
    tseriestemporal data such as TimeSeries, TemporalData,
    imagearbitrary Image or Image3D object
    audioan Audio object
  • For multichannel images and audio signals, CommonestFilter operates separately on each channel.
  • CommonestFilter[data,{r1,r2,}] computes the commonest value in blocks centered on each sample.
  • CommonestFilter assumes the index coordinate system for lists and images.
  • At the data boundaries, CommonestFilter uses smaller neighborhoods.


open allclose all

Basic Examples  (3)

Apply a majority filter to a vector of numbers:

Filter a TimeSeries:

Commonest filtering of a color image:

Scope  (11)

Data  (7)

Commonest filtering applied to arbitrary expressions:

Majority filtering of a 2D array:

Filter a quantity array:

Filter an EventSeries:

Filter an Audio signal:

Filtering a 2D grayscale image:

Apply commonest filtering to a 3D volume:

Parameters  (4)

Specify one radius to be used in all directions:

Increasing the radius will increase the regions of uniform value in images:

Majority filtering just in the first direction:

Second direction:

Commonest filtering of a 3D image in the vertical direction only:

Filtering of the horizontal planes only:

Applications  (2)

Replacing each pixel with the most common color in its neighborhood creates a posterization effect:

Majority filtering removes noise from a binary image:

Properties & Relations  (1)

Commonest filter gives the same result as MedianFilter on binary images:

Possible Issues  (1)

Majority filtering may not have the desired effect when applied to real-valued data, since all sample values may be unique:

Quantize the sample values to overcome this problem:

Neat Examples  (1)

Commonest filtering applied to random noise:

Introduced in 2008
Updated in 2012