Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:18:59+00:00 2026-05-26T22:18:59+00:00

My question is very close to this question: How do I gaussian blur an

  • 0

My question is very close to this question: How do I gaussian blur an image without using any in-built gaussian functions?

The answer to this question is very good, but it doesn’t give an example of actually calculating a real Gaussian filter kernel. The answer gives an arbitrary kernel and shows how to apply the filter using that kernel but not how to calculate a real kernel itself. I am trying to implement a Gaussian blur in C++ or Matlab from scratch, so I need to know how to calculate the kernel from scratch.

I’d appreciate it if someone could calculate a real Gaussian filter kernel using any small example image matrix.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:18:59+00:00Added an answer on May 26, 2026 at 10:18 pm

    You can create a Gaussian kernel from scratch as noted in MATLAB documentation of fspecial. Please read the Gaussian kernel creation formula in the algorithms part in that page and follow the code below. The code is to create an m-by-n matrix with sigma = 1.

    m = 5; n = 5;
    sigma = 1;
    [h1, h2] = meshgrid(-(m-1)/2:(m-1)/2, -(n-1)/2:(n-1)/2);
    hg = exp(- (h1.^2+h2.^2) / (2*sigma^2));
    h = hg ./ sum(hg(:));
    
    h =
    
        0.0030    0.0133    0.0219    0.0133    0.0030
        0.0133    0.0596    0.0983    0.0596    0.0133
        0.0219    0.0983    0.1621    0.0983    0.0219
        0.0133    0.0596    0.0983    0.0596    0.0133
        0.0030    0.0133    0.0219    0.0133    0.0030
    

    Observe that this can be done by the built-in fspecial as follows:

    fspecial('gaussian', [m n], sigma)
    ans =
    
        0.0030    0.0133    0.0219    0.0133    0.0030
        0.0133    0.0596    0.0983    0.0596    0.0133
        0.0219    0.0983    0.1621    0.0983    0.0219
        0.0133    0.0596    0.0983    0.0596    0.0133
        0.0030    0.0133    0.0219    0.0133    0.0030
    

    I think it is straightforward to implement this in any language you like.

    EDIT: Let me also add the values of h1 and h2 for the given case, since you may be unfamiliar with meshgrid if you code in C++.

    h1 =
    
        -2    -1     0     1     2
        -2    -1     0     1     2
        -2    -1     0     1     2
        -2    -1     0     1     2
        -2    -1     0     1     2
    
    h2 =
    
        -2    -2    -2    -2    -2
        -1    -1    -1    -1    -1
         0     0     0     0     0
         1     1     1     1     1
         2     2     2     2     2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this question is very easy, but I can't find the answer anywhere.
guys I know this question is very basic but I've met in few publications
this may seem like a very simple question, but I want to dump some
The title of this question is not very clear but I cannot explain what
Preamble: This is very close to this question , and I have read this
I'm doing some math with really big numbers (I'm using Python, but this question
This question was very helpful, however I have a list control in my report,
This question is very similar to SQL Server 2005: T-SQL to temporarily disable a
My question is very simple: Is there any solution to install xCode, or equivalent,
My question is very simple: is there any way to (programmatically, technically, or manually)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.