Gaussian Blur Algorithm (2024)

Usually, image processing software will provide blur filter to make images blur.

Gaussian Blur Algorithm (1)

Gaussian Blur Algorithm (2)

There are many algorithms to implement blur, one of them is called Gaussian Blur Algorithm. It utilizes Gaussian distribution to process images.

This article is to introduce Gaussian Blur algorithm, you will find this is a simple algorithm. In fact, it is a kind of data smoothing which can be used in many situations.

1. Gaussian Blur theory

The so called blur can be understood as taking a pixel as the average value of its surrounding pixels.

Gaussian Blur Algorithm (3)

On the above graph, 2 is the center point, the surrounding points are 1.

Gaussian Blur Algorithm (4)

Gaussian Blur Algorithm (5)The center point will take the average value of its surrounding points, it will be 1. From value perspective, it's a smoothing. On graphic, it's a blur effect. The center point will lose its detail.

Gaussian Blur Algorithm (6)

Obviously if the value range is very large, the blur effect is very strong.

Gaussian Blur Algorithm (7)

The above are graphs of original, 3 pixels blur radius and 10 pixels blur radius. The bigger the blur radius, the more blur the picture is.

The question now is if every point will get the average value of surrounding points, then how should we allocate weight?

If we just use simple average, it's unreasonable, because images are continuous, the closer the points in distance, the closer the relationship between points. Hence the weighted average is more reasonable than simple average, the close the points in distance, the larger the weight.

2. Weight of normal distribution

Normal distribution is an acceptable weight distribution model.

Gaussian Blur Algorithm (8)

On graphic, normal distribution is a Bell-shaped curve, the closer to the center, the bigger the value.

3. Gaussian function

The normal distribution above is one dimensional, the graph is two dimensional. We need two dimensional normal distribution.

Gaussian Blur Algorithm (9)

The density function of normal distribution is called Gaussian function. The one dimension format is :

Gaussian Blur Algorithm (10)

Here μ is the average of x, Because center point is the origin point when calculating average value, so μ equals to 0.

Gaussian Blur Algorithm (11)

Based on the one dimension function , we can derive the two dimensional Gaussian function.

Gaussian Blur Algorithm (12)

With this function, we can calculate the weight of each point.

4. Weight matrix

Assume the coordinate of the center point is (0,0), then the coordinates of 8 points which are nearest to it are:

Gaussian Blur Algorithm (13)

To calculate the weight matrix, we need to set the value of σ, σ=1.5, then the weight matrix of blur radius 1 is

Gaussian Blur Algorithm (14)

The sum of the weights of these 9 points is 0.4787147. If only calculate the Weighted average of these 9 points, then the sum should be 1, hence the above 9 values should divide 0.4787147.

Gaussian Blur Algorithm (15)

5. Calculate Gaussian Blur

With weight matrix, we can calculate the value of Gaussian Blur.

Assume we have 0 pixels now, the gray value(0-255):

Gaussian Blur Algorithm (16)

Each point multiplies its weight value:

Gaussian Blur Algorithm (17)

Now we have:

Gaussian Blur Algorithm (18)

Add these 9 values up, we will get the Gaussian Blur value of the center point.

Repeat this process for all other points, then we will get graph after Gaussian blur.

6. The process for the points at borders

If a point is at the border, there are not enough points, what should we do?

One solution is to copy all the existing points to respective places to form a new matrix.

Reference : http://www.ruanyifeng.com/blog/2012/11/gaussian_blur.html

Gaussian Blur Algorithm (2024)
Top Articles
Latest Posts
Article information

Author: Tish Haag

Last Updated:

Views: 5984

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Tish Haag

Birthday: 1999-11-18

Address: 30256 Tara Expressway, Kutchburgh, VT 92892-0078

Phone: +4215847628708

Job: Internal Consulting Engineer

Hobby: Roller skating, Roller skating, Kayaking, Flying, Graffiti, Ghost hunting, scrapbook

Introduction: My name is Tish Haag, I am a excited, delightful, curious, beautiful, agreeable, enchanting, fancy person who loves writing and wants to share my knowledge and understanding with you.