CommonestFilter
✖
CommonestFilter
filters data by replacing every value with the most common value in its range-r neighborhood.
Details

- 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.
- If more than one commonest pixel exists and the center pixel is one of them, the center pixel is used. Otherwise, the pixel is replaced with a random commonest.
- The data can be any of the following:
-
list arbitrary-rank numerical array tseries temporal data such as TimeSeries, TemporalData, … image arbitrary Image or Image3D object audio an Audio object - For multichannel images, CommonestFilter replaces each pixel by the commonest pixel vector in the neighborhood.
- 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.


Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Apply a majority filter to a vector of numbers:

https://wolfram.com/xid/0v5mspv2e197e-nepdk7

Filter a TimeSeries:

https://wolfram.com/xid/0v5mspv2e197e-fx6jf7

https://wolfram.com/xid/0v5mspv2e197e-g9fo2


https://wolfram.com/xid/0v5mspv2e197e-dulvtd

Commonest filtering of a color image:

https://wolfram.com/xid/0v5mspv2e197e-lhc1w0

Scope (11)Survey of the scope of standard use cases
Data (7)
Commonest filtering applied to arbitrary expressions:

https://wolfram.com/xid/0v5mspv2e197e-8fkivw

Majority filtering of a 2D array:

https://wolfram.com/xid/0v5mspv2e197e-cxywqj


https://wolfram.com/xid/0v5mspv2e197e-jopin9

https://wolfram.com/xid/0v5mspv2e197e-coijx0

Filter an EventSeries:

https://wolfram.com/xid/0v5mspv2e197e-62t833

https://wolfram.com/xid/0v5mspv2e197e-77v7p5


https://wolfram.com/xid/0v5mspv2e197e-18tdm0

Filter an Audio signal:

https://wolfram.com/xid/0v5mspv2e197e-p90slf

https://wolfram.com/xid/0v5mspv2e197e-em7h2s


https://wolfram.com/xid/0v5mspv2e197e-j5yrn4

Filtering a 2D grayscale image:

https://wolfram.com/xid/0v5mspv2e197e-dc0gtv

Apply commonest filtering to a 3D volume:

https://wolfram.com/xid/0v5mspv2e197e-dauq0o

Parameters (4)
Specify one radius to be used in all directions:

https://wolfram.com/xid/0v5mspv2e197e-tlzgi7

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

https://wolfram.com/xid/0v5mspv2e197e-ibus74

Majority filtering just in the first direction:

https://wolfram.com/xid/0v5mspv2e197e-gdx3zh


https://wolfram.com/xid/0v5mspv2e197e-hzoyls

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

https://wolfram.com/xid/0v5mspv2e197e-37xttb

Filtering of the horizontal planes only:

https://wolfram.com/xid/0v5mspv2e197e-5u7xo

Applications (2)Sample problems that can be solved with this function
Properties & Relations (1)Properties of the function, and connections to other functions
Commonest filter gives the same result as MedianFilter on binary images:

https://wolfram.com/xid/0v5mspv2e197e-cdiszd

Possible Issues (1)Common pitfalls and unexpected behavior
Majority filtering may not have the desired effect when applied to real-valued data, since all sample values may be unique:

https://wolfram.com/xid/0v5mspv2e197e-chqy32


https://wolfram.com/xid/0v5mspv2e197e-d9bpl5

Quantize the sample values to overcome this problem:

https://wolfram.com/xid/0v5mspv2e197e-fgy9kv

Wolfram Research (2008), CommonestFilter, Wolfram Language function, https://reference.wolfram.com/language/ref/CommonestFilter.html (updated 2016).
Text
Wolfram Research (2008), CommonestFilter, Wolfram Language function, https://reference.wolfram.com/language/ref/CommonestFilter.html (updated 2016).
Wolfram Research (2008), CommonestFilter, Wolfram Language function, https://reference.wolfram.com/language/ref/CommonestFilter.html (updated 2016).
CMS
Wolfram Language. 2008. "CommonestFilter." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/CommonestFilter.html.
Wolfram Language. 2008. "CommonestFilter." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/CommonestFilter.html.
APA
Wolfram Language. (2008). CommonestFilter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CommonestFilter.html
Wolfram Language. (2008). CommonestFilter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CommonestFilter.html
BibTeX
@misc{reference.wolfram_2025_commonestfilter, author="Wolfram Research", title="{CommonestFilter}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/CommonestFilter.html}", note=[Accessed: 19-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_commonestfilter, organization={Wolfram Research}, title={CommonestFilter}, year={2016}, url={https://reference.wolfram.com/language/ref/CommonestFilter.html}, note=[Accessed: 19-June-2025
]}