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.

DetailsDetails

  • CommonestFilter[image, r] computes the commonest value in × blocks centered on each pixel.
  • For multichannel images, CommonestFilter computes the commonest of the set of pixel vectors.
  • At the edges of an image, CommonestFilter uses smaller neighborhoods.
  • CommonestFilter works with 3D as well as 2D images, and also with data arrays of any rank.
  • CommonestFilter[image, {rrow, rcol}] uses range in height, and in width.
  • CommonestFilter[image, {rslice, rrow, rcol}] uses range in height, in depth, and in width.

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

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]=
New in 7 | Last modified in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »