Image Gaussian smoothing filter analysis

Source: Internet
Author: User


Wang yaogui (Shandong Weifang Health School, Shandong Weifang) Abstract
In image preprocessing, it is important to smooth the image, remove noise, and restore the original image. This article designed
A Gaussian filter that can change both the smoothing scale and template size, and uses it to smooth multiple images after various noises are added, after comparison of the results, we can see that Gaussian filter is used to remove noise following normal distribution.
In addition to good results, and different parameters, the smoothing scale is 2, and the template size is 7, the best effect is.
Keywords
Image preprocessing; smooth processing; smooth scale; Template size; Gaussian filter

 

1 Introduction

An original image is subject to various noises during acquisition and transmission, reducing the image quality and compromising the analysis image. Reflected to graph
There are two typical types of noise on the image. One is the salt and pepper noise with the same amplitude but random positions, and the other is the random noise with each point but random amplitude distribution. To suppress noise and modify
The image quality must be smooth. There are various methods for smooth image processing, including the mean of the neighborhood, mean filter, Gaussian filter, and mean filter of the minimum gray variance. Here we mainly analyze Gaussian filtering.
. The following are the main contents and requirements of this study:
First, open and display the corresponding image;
Second, write a program for adding noise to the image;
Third, implement Gaussian template design with different smoothing scales and different template sizes in the program, and display the design results;
Fourth, take the Lena image as an example to add noise and analyze the smooth experiment results. 2. Gaussian smoothing filter principle

Gaussian filter is a linear smoothing filter that selects values based on the shape of Gaussian Functions. Gaussian smoothing filter follows normal distribution for removal
Noise is very effective. The one-dimensional zero-mean Gaussian function is

. The Gaussian distribution parameter determines the width of the Gaussian filter. For images, the two-dimensional zero-mean discrete Gaussian function is often used as a smoothing filter. The function expression is as follows:



Formula (1)
Gaussian Functions have five important properties:
(1) Two-Dimensional Gaussian Functions have rotation symmetry, that is, the smoothing degree of the filter in all directions is the same. Generally
The edge direction is unknown. Therefore, before filtering, One Direction cannot be determined to be smoother than the other direction. Rotation Symmetry means that the Gaussian filter will not be biased towards either side in subsequent image processing.
Direction.
(2) Gaussian Functions are single-valued functions. This indicates that the Gaussian filter uses the weighted mean of the pixel neighbor to replace the pixel value of the vertex, and each adjacent
The weight of a domain pixel decreases monotonically with the distance between the point and the center point. This is important because edge is a local feature of the image. If the smoothing operation still has a large number of pixels far from the operator center
The smooth operation will make the image distorted.
(3) the Fourier transform spectrum of Gaussian Functions is single-petal. This is the fact that the Fourier transformation of the Gaussian function is equal to the Gaussian function itself.
. Images are often contaminated by unwanted high-frequency signals. The desired image features contain both low-frequency and high-frequency components. The single lobe of Gaussian function Fourier Transformation means that the smooth image will not be needed
High-frequency signals are contaminated and most of the signals are retained.
(4) the width of Gaussian filter (determining the smoothness) is evidenced by the σ parameter, and the relationship between σ and smoothing degree is very simple.
. The larger σ, the wider the Gaussian filter band and the better the smoothness. By adjusting the smoothing degree parameter σ, You can blur (Through smoothing) the image feature components and smooth the image caused by noise and fine lines.
Many do not want to compromise the amount of mutation (not smooth.
(5) Gaussian filter can be effectively implemented due to the separation of Gaussian Functions. Two-dimensional Gaussian functions can be involved in Convolution in two steps.
First, the image and the one-dimensional Gaussian function are convolution, and then the result of the convolution is the same dimension Gaussian function perpendicular to the direction. Therefore, the calculation amount of two-dimensional Gaussian filter increases linearly with the width of the filter template.
Not a square increase. These properties make it particularly useful in early image processing, indicating that Gaussian smoothing filters are very effective low-pass filters in both spatial and frequency fields.
The separation of Gaussian Functions is easy to represent:
Formula (2)
Formula (3)
 
Design of discrete Gaussian smoothing filter

In the design of Gaussian filter, the optimal approximation of Gaussian Functions is determined by the coefficient of the expanded binary form. It is obtained from the separation of Gaussian Functions.
The Gaussian filter can be implemented by convolution of two one-dimensional Gaussian filters, one along the horizontal direction and the other along the vertical direction. In fact, this operation can use a single one-dimensional Gaussian template
The image and the final convolution result image are transposed.
For large filters, the Gini coefficient is too large for most computers, but any large Gaussian filter can pass through repetition.
Use a small Gaussian filter. Another way to design a Gaussian filter is to directly calculate the template value from the discrete Gaussian distribution.
Formula (5)
C is the normalization coefficient, and the above formula is re-represented
Formula (6)
Select appropriate σ 2
You can evaluate the value in the window to obtain the core or template.
The second method is used in this experiment. Select N and σ 2
Value, and then according to the formula
(4) Calculate the elements in the bottom right corner of the template, and then calculate the upper and lower Symmetry Based on the left and right sides of the Gaussian template (1
Copy the template structure of C7 × 7 to the other three regions to obtain the elements of the entire template. Then sum all template elements and take the reciprocal to obtain the Normalization Coefficient. The main implementation of template elements in the program is as follows: for (I = 0; I <n + 1; I ++) // obtain the template size (2n + 1) (2n + 1) in the lower right corner {for (j = 0; j <n + 1; j ++) {T = (float) (I * I + J * j) /(float) m_b2; // m_b2 indicates the smooth scale ftemp [I * (n + 1) + J] = (float) (1.0/exp (T/2);} c = (INT) Ceil (1/ftemp [(n + 1) * (n + 1) -1] + 0.5); // calculate the Normalization Coefficient for (I = 0; I <n + 1; I ++) // pay the value {for (j = 0; j <n + 1; j ++) {itemp [(n + I) * (2 * n + 1) in the lower right corner of the template) + (n + J)]
= Int (ftemp [I * (n + 1) + J] * C + 0.5) ;}} for (I = N; I <2 * n + 1; I ++) // pay the value {for (j = 0; j <n + 1; j ++) {itemp [I * (2 * n + 1) in the lower left corner of the template) + J] = itemp [I * (2 * n + 1) + (2 * n-j)] ;}} for (I = 0; I <N; I ++)
// The upper half of the template is paid {for (j = 0; j <2 * n + 1; j ++) {itemp [I * (2 * n + 1) + J] = itemp [(2 * n-I) * (2 * n + 1) + J] ;}} for (I = 0; I <2 * n + 1; I ++) // calculate the total coefficient {for (j = 0; j <2 * n + 1; j ++) {COF + = (float) itemp [I * (2 * n + 1) + J] ;}} COF = (float) (1.0/COF ); for example, 3 × 3, 5 × 5, 7 × 7, Gaussian TEMPLATE 1.

(7) The dialog box structure 1 of the Gaussian filter designed in this experiment is shown in. A) σ = 1, n = 3 templates B) σ = 2, n = 5 of the template c) σ = 2, TEMPLATE 1 when n = 7 select different smoothing parameters and display the template element Dialog Box 4 experiment results, analysis and summary

This experiment uses the 256x256
Lena (Gray and colored) images are de-noise, as shown in figure 2.
Compared with the effects of several sets of images in the figure, we can see that when the smooth scale is 1 and the template changes from 3x3 to 5x5, the smooth effect is obviously better, the overall brightness of the image is also improved, which is closer to the source image (
Comparison chart. B and C ). Similarly, when the smooth scale is 2, the effect of the template 7x7 is much better than that of the 5x5 (compared to figure. D and E ). At the same time, the two groups before and after the comparison are obvious, smooth Scale
The effect of 2 is much better than that of 1. However, as the smoothing scale increases, especially the template size increases, the smoothing takes a longer time. Therefore, we need to weigh the two in practical application, and adopt
Different parameters.


A) original image after Noise addition B) σ = 1, n = 3
Smooth Result c)
Smoothing result of σ = 1, n = 5 d) σ = 2, n = 5
E) smoothing result of σ = 2, n = 7 Fig 2 smooth Effect of gray-scale color images in different smoothing scales and templates for hours

 


In addition, the Gaussian templates with a scale of 2 and 7x7 are applied to Pretzels, random images, and Gaussian noise images respectively.
Step by step, analyze the denoising effect of Gaussian filter on different noises. The result is compared with 3.
Through comparison, it is found that Gaussian filtering has a good effect on the removal of random noise and Gaussian noise (especially noise that follows normal distribution),
The removal of salt and pepper noise is not good. It seems that the noise is reduced while the noise is also increased. Therefore, when performing smooth processing, different filters must be used for different image noises to achieve good results. A) image before and after salt and pepper noise processing B) image before and after random noise processing c) image before and after Gaussian noise processing 3 σ = 2, smoothing of different noisy images at n = 7 hours (May 26) male, Senior Lecturer, undergraduate, mainly engaged in Computer Teaching and electrochemical teaching.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.