CommonestFilter

CommonestFilter[data,r]

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

CommonestFilter[data,{r1,r2,}]

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

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:
  • listarbitrary-rank numerical array
    tseriestemporal data such as TimeSeries, TemporalData,
    imagearbitrary Image or Image3D object
    audioan 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 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:

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).

BibTeX

@misc{reference.wolfram_2021_commonestfilter, author="Wolfram Research", title="{CommonestFilter}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/CommonestFilter.html}", note=[Accessed: 21-September-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_commonestfilter, organization={Wolfram Research}, title={CommonestFilter}, year={2016}, url={https://reference.wolfram.com/language/ref/CommonestFilter.html}, note=[Accessed: 21-September-2021 ]}

CMS

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