Introduction to Gaussian (kernel) Functions

Source: Internet
Author: User

Http://changxiaofu123.blog.163.com/blog/static/12963882020099794814769/

Introduction to Gaussian (kernel) Functions

Pattern recognition, Algorithm

Radial Basis Function (RBF) is a scalar function that is symmetric along the radial direction. It is usually defined as a monotonic function of the Euclidean distance between a point of X and a certain center of XC in space. It can be recorded as K (| X-XC |), and its function is usually local, that is, when X is far from XC, the function value is very small. The most common radial basis function is the Gaussian Kernel Function in the form of K (| X-XC |) = exp {-| X-XC | ^ 2/(2 * σ) ^ 2)} Where XC is the kernel function center, σ is the function width parameter, controls the radial scope of the function.

Gaussian Functions have five important properties that make them particularly useful in early image processing. these properties indicate that Gaussian smoothing filters are very effective low-pass filters in both spatial and frequency domains, and are effectively used by engineers in actual image processing. gaussian Functions have five very 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 of an image is unknown in advance. Therefore, before filtering, it is impossible to determine a direction that requires more smoothness than the other side. rotation Symmetry means that the Gaussian smoothing filter will not be in any direction in subsequent edge detection.

(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 point, and the weight of the pixel in each neighbor increases or decreases monotonically with the distance between the point and the center point. this is important because the edge is a local feature of the image. If the smoothing operation still plays a significant role in pixels far from the operator center, the smooth operation will distort the image.

(3) the Fourier transform spectrum of Gaussian Functions is single-petal. as shown below, this property is a direct inference of 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 (noise and fine lines ). the desired image features (such as edges) contain both low-frequency and high-frequency components. the Gaussian function Fu's transformation of a single valve means that the smooth image will not be contaminated by unwanted high-frequency signals, while retaining most of the required signals.

(4) Gaussian filter width (determining the smoothness) is characterized by σ, 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 σ, the image features can be over-blurred (over-smooth) and Smoothing image noise and fine grain caused by excessive amount of unwanted mutation (not smooth) compromise.

(5) Gaussian filter can be effectively implemented due to the separation of Gaussian Functions. two-dimensional Gaussian function convolution can be performed in two steps. First, the image and one-dimensional Gaussian function are convolution, and then the convolution result is perpendicular to the same dimension Gaussian function convolution. therefore, the calculation amount of two-dimensional Gaussian filter increases linearly with the width of the filter template instead of the square.

Alf = 3;

For I = 1: N

A (I) = exp (-(i-n1). ^ 2)/(2 * alf ^ 2 ));

For j = 1: N

B (I, j) = exp (-(i-n1) ^ 2 + (j-n1) ^ 2)/(4 * alf)/(4 * pI * alf );

End

End

Images are often contaminated by random intensity signals (also known as noise. some common noises include salt & pepper noise, impulsive noise, and Gaussian noise. pretzels contain random black and white intensity values. however, impulsive noise only contains random white intensity values (Positive pulse noise) or black intensity values (negative pulse noise ). unlike the first two, Gaussian noise contains noise whose intensity is subject to Gaussian or normal distribution. the Research of filtering is to eliminate noise interference.

Image filtering generally includes airspace filtering and frequency domain filtering. Frequency Filtering requires first Fourier transformation to the frequency domain processing and then reverse conversion back to the space domain to restore the image. spatial filtering directly performs spatial conversion on the image data for filtering purposes. It is a neighborhood operation, that is, the value of any pixel in the output image is calculated by using a certain algorithm, based on the value of the pixel in a certain neighborhood around the pixel in the input image. If the output pixel is a linear combination of input pixel neighboring pixels, it is called linear filtering (for example, the most common mean filtering and Gaussian filtering ), otherwise, it is non-linear filtering (median filtering, Edge Preserving filtering, etc ).

The linear smoothing filter has good effects on Gaussian noise removal, and in most cases, it also has good effects on other types of noise. The linear filter uses the pixel weighting sum in the continuous window function to implement filtering. In particular, the weighting factor of the same pattern can act in each window, which means that the linear filter remains spatial, so that the convolution template can be used for filtering. If different parts of the image use different filter weighting factors and the filter can still be used to complete the weighting operation, then the linear filter is space variable. Any filter that is not a pixel weighted operation belongs to a non-linear filter. non-Linear Filters can also remain spatial, that is, they can perform the same operation at any position of the image without considering the changes in the image position or space.

Filtering is generally described by convolution or correlation, while linear filtering is generally described by convolution. They are very similar, but they are still different. Let's take a look at their specific differences based on the related and convolution calculation processes:

Convolution calculation steps:

Related calculation steps:

For example, magic (3) = [8 1 6; 3 5 7; 4 9 2], after rotating 180 degrees, it becomes [2 9 4; 7 5 3; 6 1 8].

The optimal approximation of Gaussian Functions is determined by the coefficient of the expansion of the binary model. In other words, the nth line of the Yang Hui triangle (also called Pascal triangle) is used as a one-dimensional approximation of Gaussian filter with N points, for example, the five-point approximation is:

1 4 6 4 1

They correspond to 5th rows of the Pascal triangle. this template is used to smooth the image horizontally. it has been pointed out that the two-dimensional Gaussian filter can be achieved by convolution of two one-dimensional Gaussian filters, one along the horizontal direction and the other along the vertical direction. in reality, this operation can be done by using a single one-dimensional Gaussian template to transpose the image between two convolution and the final convolution result image. this technique achieves excellent filtering when the template size N is about 10. for large filters, there are too many latent coefficient for most computers. however, any large Gaussian filter can be achieved by repeatedly using a small Gaussian filter. σ of the binary approximation of Gaussian filter can be calculated by fitting the least variance of the binary coefficient with Gaussian function.

Another way to design a Gaussian filter is to calculate the template weight directly from the discrete Gaussian distribution. For ease of calculation, we generally want the filter weight to be an integer. Take a value at a corner of the template, and select a K to set the value to 1. This coefficient can be used to integer the filter. Because the sum of the template weights after Integer Conversion is not equal to 1, to ensure that the image's even gray area is not affected, you must normalize the weights of the filter template.

A discrete Gaussian filter can be formed by the sample value of the Gaussian filter or the Gini coefficient of the Gaussian filter. when a discrete Gaussian filter is used for Convolution, the result is a larger Gaussian discrete filter. if an image is smoothed using the N * n discrete Gaussian filter and then smoothed using the M * m discrete Gaussian filter, then the smoothing result is equivalent to (n + M-1) * (N + M-1) discrete Gaussian filter smoothing results are the same. in other words, the N + M-1 line is formed by convolution of the N and m rows in the Yang Hui triangle.

If the image is filtered by convolution, two different functions can be used in MATLAB to implement conv2 and imfliter. Their calling methods are as follows:

Img_n = conv2 (IMG, G, 'same'); and img_n = imfilter (IMG, G, 'conv ');

The results of these two functions are exactly the same.

Img_n = imfilter (IMG, g); % use related operation Filtering

The following is a simple example of using the same Gaussian filter kernel function. The effect of related operations and convolution operations on image smoothing can be directly attachedProgramView.

From the results, we can see that the correlation operation and convolution operation have little difference in the timeliness of image smoothing filtering. When the template size is n> 50. The coefficient of the boundary is very small and has little impact on the operation. Therefore, the differences between the smooth results are very subtle and almost invisible to the naked eye.

Example. m

IMG = double (I );

Alf = 3;

B (I, j) = exp (-(i-n1) ^ 2 + (j-n1) ^ 2)/(4 * alf)/(4 * pI * alf );

End

K = uint8 (imfilter (IMG, B ));

J = (img_n2)-img_n;

Flag = mean (J (:))

Figure (2), surf (B );

How can we discretization Gaussian Kernel expressions?

For a Gaussian convolution kernel with zero mean, know its variance and how to find its discrete expression form,
For example, in MATLAB, input filter = fspecial ('gaussian ', 3, 1)
You will get:
Filter
=
0.0751 0.1238 0.0751
0.1238 0.2042 0.1238
0.0751 0.1238
0.0751
How can I find this? I thought about it myself and wrote a program, which is consistent with the program result of Matlab.
Sigma = 3; % Sigma
Delta = 1;
% Value Step 1
Width = 9; % convolution kernel size
Filter = zeros (width, width );
For
I =-1 * floor (width/2): floor (width/2)
For
J =-1 * floor (width/2): floor (width/2)
Filter (I + 1 + floor (width/2), J + 1 + floor (width/2) = exp (-1 * (I * delta) ^ 2 + (J * delta) ^ 2)/(2 * Sigma ^ 2)/(2 * Sigma ^ 2 );
End
End

Filtersum = sum (filter ));
Filter = filter/filtersum; my note: actually in the first articleArticleUnderstand the concept and principle of the radial basis function and the MATLABCodeImplementation, you can master
Continuous filter functions-> discrete templatification method.

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.