Spatial Filters

Apply mean and median spacial filters to any Image!

Upload an Image


What is a Mean or Median Filter? - Mean or median filters are image processing techniques that reduces the abruptness of color transitions in an given image by taking a arithmetic mean or the median on the RGB values of surrounding pixels. This image is fully processed when every pixel has its neighbour's mean or median taken. The amount of neighbours can be varied using the filter width - for example a width of 1 means that any neighbour within 1 pixel is used for the mean or median calculation. This yields 8 neighbours in (and the pixel itself) in the calculation. Similarily for a 2-width calculation - 24 neighbours are used for the calculation. Increasing the filter width will increase the smoothness of the image but also decrease image quality.

Original Image
RGB:
{0, 0, 0}
RGB:
{0, 0, 0}
RGB:
{0, 0, 0}
RGB:
{5, 5, 5}
RGB:
{5, 5, 5}
RGB:
{5, 5, 5}
RGB:
{10, 10, 10}
RGB:
{10, 10, 10}
RGB:
{10, 10, 10}
First Pixel Neighbours (width = 1)
RGB:
{2, 2, 2}
RGB:
{0, 0, 0}
RGB:
{0, 0, 0}
RGB:
{5, 5, 5}
RGB:
{5, 5, 5}
RGB:
{5, 5, 5}
RGB:
{10, 10, 10}
RGB:
{10, 10, 10}
RGB:
{10, 10, 10}

Note: Int Division (5+5+0+0) // 4 = 2

First Pixel Neighbours (width = 2)
RGB:
{5, 5, 5}
RGB:
{0, 0, 0}
RGB:
{0, 0, 0}
RGB:
{5, 5, 5}
RGB:
{5, 5, 5}
RGB:
{5, 5, 5}
RGB:
{10, 10, 10}
RGB:
{10, 10, 10}
RGB:
{10, 10, 10}

Note: (3(0) + 3(5) + 3(10)) // 9 = 5

How This Algorithm Applies the Filter - This algorithm exclusively operates on the Portable Pixel Map(.ppm) format. Pixel map images are easy to read because each pixel is stored as a plain-text, space delimited RGB value. For example, a dark pixel has the value "0 0 0". Any uploaded image is converted to ppm image first and a filter is applied. The image is then converted back to a more optimized format for download. This conversion is necessary because ppm images are easy to work with but occupies a large space so it is suboptimal to transfer it back.

Original Image
img/orig.png
Median Filter (Width = 6)
img/median13.png
Mean Filter (Width = 5)
img/mean11.png

How Long Will an Uploaded Image be Kept For? - A image goes through 4 stages on the server.

First, it is converted to a PPM format (Regardless of the original format), the original image is deleted after this step.

Second, the PPM image is filtered and a new filtered PPM image is produced, the unfiltered image is deleted after this step.

Third, the filtered PPM image is converted the a filtered PNG format, the filtered PPM image is deleted after this step.

Last, the filtered PNG is send back to you and a worker thread will remove this image after 60 seconds.

TLDR: 60 seconds after the image is sent back to you.