"Signal, image, Matlab" How to get the integer template of Gaussian filter

Source: Internet
Author: User

"Signal, image, Matlab" How to get the integer template of Gaussian filter

How do I get an integer template for a Gaussian filter? This problem bothered me for two days, internet search code, basically all generated decimals, some documents to write a 3*3,5*5,7*7 integer form, but did not say how to get, should say is I did not look carefully, now suddenly, as long as the upper left corner of the element into 1 can ah . I thought I was going to get out of this high-level way, and I was dizzy.

Ivigos Distribution formula:


To get the integer template of the Gaussian filter, we start with this formula, which is in the form of three-dimensional coordinates:

We want the integer template of the Gaussian filter equivalent to the three-dimensional graphics in the bottom surface (the bottom grid, that is, discretization, the computer can not handle the continuous east) projection, the height of the surface into the grid values, this is the template we want.

Formulas for calculating integer templates

Assuming that our template is placed in matrix m, the size of M is (2k+1) * (2k+1), then the value of M (i,j) is:

Note: This is the result of a continuous formula, except that M is a matrix, the origin is in the middle of the matrix, so there is (i-k-1) and (j-k-1) is to let the origin point to the middle of the matrix.

A MATLAB code
clear;k=1;% half of the template lengthrow =2*k+1;% Template LengthCol =2*k+1; sigma2=1;% Variance for I=1: Row for J=1: Col fenzi=double (I-k-1)^2+(J-k-1)^2); AI,J)=Exp(-fenzi/(2*SIGMA2))/(2*Pi*SIGMA2);EndEndA% display in decimal formC= Floor(A.*(1/A (1,1)));% left upper corner to 1 (think of a long time how to get out of the whole, as long as this can be, depressed)

This code gets a decimal and integer template for a 7*7,sigma=1 Gaussian filter, as follows:
Decimal:

Integer:

Thought for a long time how to get an integer form of the template, inadvertently from the Internet to see the upper left corner of the elements into 1 can be, I can only say that his skull is really slow ah.

Two points to illustrate
    • If the above integer template is to be used for filtering, normalization is required to add a factor to the front of the entire template, which is: 1/(Sum of all integers).
    • The generated template is related to one thing in the formula:Sigma, which has a significant impact on the number of generated templates. Here to a different sigma of a Gaussian distribution map, two-dimensional similar to understand the Sigma value on the function of the graph effect can be:

      The larger the Sigma, the more concentrated the distribution.
Give a few different size, different sigma integer templates




The reason to put these templates, you can find that the value of sigma on the template has a large impact, so how to take Sigma, this should be an empirical problem.

"Signal, image, Matlab" How to get the integer template of Gaussian filter

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.