Gaussian filtering and Gaussian blur

1. Gaussian distribution

Gaussian distribution in one dimension:

Density function:

Graph of the density function:

Distribution function:

 Probability density for the standard normal distribution:

When μ=0,σ=1,

Some properties of the normal distribution:

2. Two-dimensional Gaussian function:

The general image is as follows:

Joint probability density of (X,Y) for a two-dimensional random variable:

It is said that (X,Y) obeys a bivariate normal distribution, which is recorded as (X,Y)∼N(μ1,μ2,σ12,σ22,ρ), and the value range of the five parameters is

−∞<μ1,μ2<+∞,   σ1,σ2>0,   −1≤ρ≤1

where ρ is the correlation coefficient of X and Y,

3. Multivariate normal distribution

Suppose a vector x obeys a multivariate Gaussian distribution with mean vector μ and covariance matrix Σ, then p

suppose 

first

secondly

Therefore, the two-dimensional Gaussian function is defined as follows

More generally defined as

 Gaussian blur principle

 Blur is to take the average value of surrounding pixels every pixel, which is a smoothing effect in value, which is equivalent to blurring effect in graphics, and the middle point loses details.

Obviously, when calculating the average value, the larger the surrounding range is, the stronger the blur effect will be.

Each point takes the average value of the surrounding pixels, so how to assign the weight of the surrounding pixels? It is unreasonable to use simple average, which ignores the continuity and correlation between image pixels. The images are all continuous, the closer the points are, the closer the relationship is, and the farther the points are, the more distant the relationship is, so the weight of the point near the distance is greater, and the weight of the point far away is small. Clearly, the normal distribution is a desirable weight distribution pattern.

When calculating the average value, the center point is used as the origin, and other points are assigned weights according to their positions on the normal curve to obtain a weighted value.

Weight matrix:

In order to calculate the weight matrix, the value of σ needs to be set. Assuming σ=1.5, the weight matrix with a blur radius of 1 is as follows:

 The sum of the weights of these 9 points is equal to 0.4787147. If only the weighted average of these 9 points is calculated, the sum of their weights must be equal to 1 , so the above 9 values ​​must be divided by 0.4787147 to obtain the final weight matrix.

Compute Gaussian blur:

Assuming that there are 9 pixels, the gray value (0-255) is as follows:

 Each point is multiplied by its own weight value (correlation operation, matrix point multiplication):

Adding up these 9 values ​​is the value of the Gaussian blur at the center point. Repeating this process for all points yields a Gaussian blurred image. If the original image is a color image, Gaussian blur can be performed on the three channels of RGB respectively. 

Guess you like

Origin blog.csdn.net/weixin_62705892/article/details/127262145