Image Processing

Image Pre-Processing plays a great role in deep learning cause without it we make the networks learn a lot of noise. Yes! a lot of noise. There are several image processing filters that we can apply but in this article I’m going only the most common ones which we apply in our projects.
So with that let’s start !!

1. Mean Filter:

  • The Mean filter or Average Filter is a low-pass filter that computes the local average of the pixel intensities at any specific point.
  • The impulse response of a Mean Filter can be any of the form seen here.
Mean Filter Impulse response
  • The mean filter is used to reduce the noise in an image.
  • If there are some white Gaussian noise present in the image, then the Mean Filter will reduce the noise since it averages over its neighbourhood, and hence the white noise of the zero mean will be suppressed.
Mean Filter on Mona Lisa

2. Median Filter

  • A 2D Median Filter replaces each pixel in a neighbourhood with the median pixel intensity in that neighbourhood based on the filter size
  • The Median filter is good for removing salt and pepper noise. This type of noise presents itself in the images in the form of black and white pixels and is generally caused by sudden disturbances while capturing the images.
Median Filter on Mona Lisa

3. Gaussian Filter

  • The Gaussian Filter is a modified version of the Mean Filter where the weights of the impulse function are distributed normally around the origin.
  • Weight is the highest at the center of the filter and falls normally away from the center.
  • The Gaussian Filter, when displayed as an image, has the highest intensity at the origin and then diminishes for pixels away from the center.
Gaussian Filter Image
  • Gaussian filters are used to reduce noise by suppressing the high frequency components. However in its pursuit of suppressing the high frequency components it ends up producing a blurred image, called Gaussian Blur.
  • The tactics which we can apply is as follows:
    Step-1 : Noisy-image * Gaussian Filter = Gaussian Blurred image.
    Step-2 : Noisy-image — Gaussian Blur = High-freq components
    Step-3 : Noisy-image + 0.025 ×High-freq components = Stable sharp image
Gaussian Filter Application Algorithm
Gaussian-Filter Application on Mona Lisa

4. Sobel Edge Detection Filters

  • The Sobel Edge Detectors are extensions of the Horizontal and Vertical Gradient filters. Instead of taking gradient at the point, it also takes the sum of the gradients at the points on either side of it. Also, it gives double weight to the point of interest.
  • The Horizontal Sobel filter detect edges in the horizontal direction, whereas the Vertical Sobel filter detect edges in the vertical direction.
  • Both are high pass filters since they attenuate the low frequencies from the signals and capture only the high frequencies components within the images.

Then magnitude of I’(x,y) can be used as the pixel intensity of the combined Sobel filter.

where C(x,y) denotes pixel intensity function for the combined Sobel filter.

Sobel-Edge detection filter on Mona Lisa

There are also several other filters like Identity Filter, Canny Filter, Weiner Filter etc. which are used for image pre-processing for feature extraction or getting insight of the input image.

A quick easy guide is as follows:

You can look at my GitHub for the codes: https://github.com/lucifermorningstar1305/deeplearning/tree/master/image_processing

--

--

Adityam Ghosh
Journey to Machine Learning/Deep Learning/Artificial Intelligence

Machine Learning Engineer 🤖 | Kaggle Notebook Expert | Python & Julia Fan 👨‍🎤