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.