This is documentation for Mathematica 7, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

CommonestFilter

CommonestFilter[image, r]
transforms image by replacing each pixel with the most common pixel value in its range r neighborhood.
CommonestFilter[data, r]
applies commonest filtering to an array of data.
  • CommonestFilter[image, r] computes the commonest value in (2r+1)×(2r+1) blocks centered on each pixel.
  • CommonestFilter[image, {r1, r2}] uses neighborhoods with vertical range r1 and horizontal range r2.
  • In CommonestFilter[data, ...], data can be an array of any rank, and can contain symbolic as well as numerical entries.
Replacing each pixel with the most common color in its neighborhood creates a posterization effect:
Apply commonest filtering to a vector of numbers:
Replacing each pixel with the most common color in its neighborhood creates a posterization effect:
In[1]:=
Click for copyable input
Out[1]=
 
Apply commonest filtering to a vector of numbers:
In[1]:=
Click for copyable input
Out[1]=
Commonest filtering applied to arbitrary expressions:
Majority filtering removes noise from a binary image:
Commonest filtering applied to random noise:
New in 7