Blogs/Image Filtering

Image Filtering

mesakarghm Mar 17 2021 1 min read 249 views
Computer Vision
image filtering

Filtering is one of the conventional image preprocessing steps. Various kinds of filtering can be done on an image during preprocessing. Some examples are: Max Filter, Min Filter, Median Filter, Mean Filter, etc. 

A Max-Filter is an image filter that removes the negative outlier present in the image. It replaces each pixel value of an image with the maximum value of its neighbourhood pixel window. The brighter terms are dilated and the darker objects are eroded.

Similarly, a Min-Filter picks up the minimum value of the neighbourhood pixel window and assigns it to the current pixel. The dark values present in an image are enhanced by a minimum filter.

Let's say we start with the following image:

Image Filtering

Applying max filtering, we get the following image:

Image Filtering

Applying min filtering, we get the following image:

Image Filtering

Below is an implementation on how you can use Max Filter on image using the image processing library Pillow. 


Learn and practice this concept here:

from PIL import Image

from PIL import ImageFilter

imageObject ="./image.jpg");

maxFilter1x= imageObject.filter(ImageFilter.MaxFilter)

maxFilter2x = maxFilter1x.filter(ImageFilter.MaxFilter)

minFilter1x = imageObject.filter(ImageFilter.MinFilter)

minFilter2x = minFilter1x.filter(ImageFilter.MinFilter)