Master LLMs with our FREE course in collaboration with Activeloop & Intel Disruptor Initiative. Join now!

Publication

Gaussian Blurring — A Gentle Introduction
Latest   Machine Learning

Gaussian Blurring — A Gentle Introduction

Last Updated on July 17, 2023 by Editorial Team

Author(s): Vijay Vignesh

Originally published on Towards AI.

Source: Coreldraw

Gaussian blurring is an image processing technique used to reduce the noise and smoothen out an image. Before I get into Gaussian blurring, let me touch upon the concept of noise and why they are important. Noise basically refers to random fluctuations in the pixel values that are not present in the original image. Noise can occur due to various factors like sensor errors, transmission errors or image compressions. More often than not, noise is not visible to the naked eye. So why does it matter? Because most of the image processing techniques, like edge detection or corner detection work with an assumption that the images are clean and devoid of noise. These irregularities in pixel values greatly affect the accuracy and reliability of such algorithms.

Although both the images above look similar to the naked eye, the difference can be noticed when we zoom into a specific portion of the image. (Reference image author: svstudioart on Freepik)

Next, let’s examine the impact of the noisy image on other image processing algorithms, particularly edge detection. When we apply an edge detection algorithm to both the original and noisy images for reference, we observe noticeable differences in the results. I have used canny edge detection algorithm here, but the same can be inferred from the other algorithms as well.

Canny Edge detector applied on the original image and the noisy image. Note how much difference it creates on the output of the algorithm. (Photo by Karsten Würth on Unsplash)

Now that we know how important it is to remove noise from an image, let’s look at one of the most commonly used techniques for noise removal — Gaussian Blurring.

The basic idea behind Gaussian blurring is to replace each pixel value with a weighted average of its neighboring pixels. This makes sure that there are no irregular spikes in the intensity of pixels in a neighborhood. It is called Gaussian blurring since the weighted average, in this case, comes from a Gaussian function. Gaussian blurring is just one of several blurring methods available. Other blurring techniques include box blurring, median blurring, and more. Each method employs a different weighted average function, leading to different blurring effects and applications in image processing tasks.

Let’s look at the Gaussian function:

Source: packpub

Although the function looks complex, its underlying concept is rather straightforward. The kernel block is designed such that the center holds the highest value, and as we move away from the center, the values progressively decrease with distance. Here is an example of a Gaussian kernel for reference.

Gaussian function visualized in both 3D and 2D formats.

Gaussian blurring is applied to an image in the following way:

  1. A kernel of a specific size is defined, typically an odd-sized square matrix (3×3, 5×5, 7×7, etc.).
  2. Place the kernel over each pixel in the image and perform element-wise multiplication between the kernel and the corresponding neighborhood of pixels.
  3. Sum up the products obtained in the previous step to calculate the blurred value for each pixel. This blurred value represents a weighted sum of the neighboring pixels.
  4. Repeat steps 2 and 3 for every pixel in the image to obtain the resulting blurred image.

Here is a depiction illustrating the working principle of the algorithm. A 3×3 Gaussian Kernel is used to blur the image patch below. The Gaussian kernel is generated using the formula given above with σ =1.0.

The image is padded to depict how the Gaussian blurring takes place. Here, a 3×3 Gaussian kernel is moved across the image, and the weighted sum of the neighboring pixels is taken as the pixel intensity at a given position.

Finally, let’s look at how Gaussian blurring improves the image processing algorithms. For the sake of continuity, I’ll use the same canny edge detection algorithm which I had used previously. Since the Gaussian blurring removes the irregular fluctuations in the image, the edge detection algorithm produces more accurate and reliable results. In the example provided below, we can observe the significant impact of Gaussian blurring on the edge detector algorithm.

Note the drastic difference in the edge detection algorithm.

By reducing noise and smoothing out the image, Gaussian blurring helps the image processing algorithms to focus on detecting meaningful features and structures in the image rather than being influenced by random fluctuations in pixel values. Whether it is object recognition, image segmentation, feature extraction, or other image processing tasks, the ability to identify and extract meaningful information from the image is crucial. That is why Gaussian blurring is widely employed as a preprocessing step before applying any image processing technique.

That’s it, folks! Hopefully, now you have an idea of what Gaussian Blurring is, why it is used, and how important it is in computer vision. Stay tuned for more exciting topics in the realm of computer vision.

See you soon!

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓