Image Filteringmesakarghm Mar 17 2021 1 min read 249 views
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:
Applying max filtering, we get the following image:
Applying min filtering, we get the following image:
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.open("./image.jpg"); maxFilter1x= imageObject.filter(ImageFilter.MaxFilter) maxFilter2x = maxFilter1x.filter(ImageFilter.MaxFilter) maxFilter1x.show() maxFilter2x.show() minFilter1x = imageObject.filter(ImageFilter.MinFilter) minFilter2x = minFilter1x.filter(ImageFilter.MinFilter) minFilter1x.show() minFilter2x.show()