The goal of this tutorial is to reveal major details about **Gaussian blur** and how to use it for mage processing and machine vision taks. **FivekoGFX** implements a WebGL version of *Gaussian filter* and uses GPU power by *OpenGL shaders* (GLSL). This makes it suitable for direct use into HTML5 web apps and to achieve good performance.

## What is Gaussian blur?

*Gaussian blur* is a non-linear noise reduction** low-pass filter** (LP filter) widely applicable for **image processing** and **computer vision **tasks. The visual effect of this filter is a *smooth blurry image*, meaning it reduce intensity variations between adjacent pixels. Gaussian filter performs better than other uniform low pass filters like the Mean filter and this makes it favorite pre-processing step in* image processing* and *objects recognition* algorithms.

## How does Gaussian Blur works?

The *Gaussian filter* works by convolving the input image with a Gaussian kernel. The convolution with such a kernel performs a weighted average of the current pixel’s neighborhoods in a way that distant pixels receive lower weight than these at the center. The result of this is a blurry image with better edges than other uniform smoothing algorithms. The kernel calculation uses the following math equations for corresponding weights:

### Gaussian function 1D

### Gaussian function 2D

The calculation of 2D *Gaussian function* is represented by the following equation (2):

In practice it is better to take advantage of the **Gaussian function** separable properties. This property allows blur execution in two separate steps and apply a one dimensional kernel instead of the *2D Gaussian filter*. As a result, we can achieve a quick blur effect by dividing its execution horizontally and vertically. For Gaussian filter calculation we use equations mentioned above and if processing uses a separable **Gaussian blur** then for the kernel math use the first equation. Note that when converting continuous values to discrete ones, the total Gaussian kernel sum will be different than one. This leads to **brightening** or **darkening** of the image, so in practice we **normalize** the kernel by dividing each of its elements by the sum of all of them.

### Features

We can summarize some of the Gaussian’s filter features:

- It is a
**separable filter**– can use it as a separable 1D kernel and process rows and columns separably - The use of ‘weighted average’ masks makes it better for edge detection than some uniform blurring filters
- Multiple iterations with same gaussian filter to an image has the same effect as applying a single, larger gaussian blur
- Useful as a pre-processing step for image size reduction

## Gaussian Discrete Approximations

In many cases it is enough to use an approximation of *Gaussian function*. Below are listed several famous masks which are frequently used in computer vision. The pictures reveal the kernel values together with the corresponding scale factor as well as the corresponding 1-dimensional separable vectors.