Understanding Gaussian smoothing/filtering

  • Context: Graduate 
  • Thread starter Thread starter pamparana
  • Start date Start date
  • Tags Tags
    Gaussian
Click For Summary

Discussion Overview

The discussion revolves around Gaussian smoothing and filtering, focusing on the properties of Gaussian kernels, particularly in discrete and multi-dimensional contexts. Participants explore questions related to normalization factors, the sum of kernel values, and the implications of smoothing techniques in image processing.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant questions the necessity of a scaling factor in a discrete Gaussian kernel and whether it ensures the sum of values equals 1, referencing the area under the Gaussian curve.
  • Another participant asserts that the sum of all rescaled values in the entire kernel should equal 1, while also noting that the sum of kernel values in each 1-D kernel should be 1 when smoothing along each axis separately.
  • There is a discussion about the implications of discretization and windowing on the sum of kernel values, with a suggestion that the correct result would be obtained through integration from negative to positive infinity.
  • A participant mentions that if the discrete kernel is sufficiently wide (e.g., 3 standard deviations), normalization may not be critical as the sum will approximate unity.
  • Concerns are raised about the normalization factor's validity for discrete kernels, particularly when the standard deviation (sigma) is less than 1, indicating that the relationship between the normalization factor and sigma is not straightforward.
  • One participant expresses uncertainty about the normalization factor's derivation and its relationship with sigma, seeking clarification on this aspect.

Areas of Agreement / Disagreement

Participants express differing views on the necessity and implications of normalization in Gaussian smoothing, with no consensus reached on the best approach for scaling kernel values across dimensions.

Contextual Notes

The discussion highlights limitations related to the assumptions made about kernel values, the effects of discretization, and the conditions under which normalization factors apply, particularly regarding the standard deviation.

pamparana
Messages
123
Reaction score
0
Hello,

I was looking at the explanation for Gaussian smoothing found here:

http://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htm"

Now, figure 3 shows a discrete Gaussian kernel approximation. I have 2 questions:

1: Why is there a scaling factor (1/273)? Is it so that the sum of the discrete values is 1. I remember reading somewhere that the area under the Guassian curve is supposed to be 1. Is this also true in more than one dimension?

2: This is a more practical question. I am looking at some source code which attempts to smooth a 3D image using the separable technique and smoothes along each axes separately. So, it does it as follows:

float kernelSum = 0.0;
for (int i = 0; i < 3; ++i) {
for (int j = -radius; j < radius; ++j) {// The kernel of a given radius...
// Compute kernel value at the given point
...
kernelSum += computed_kernel_value;
}
for (int j = -radius; j < radius; ++j) {
// Scale all kernel values in current axes by kernelSum
}
}

Now, my question is shouldn't it be scaling the kernel after it has computed the values in all 3 dimensions? Right now, it scales each axes by the sum of the kernel values along that axes. This ensures that the sum of the values along a particular axes is 1. However, shouldn't the sum along all the axes be equal to 1?

To be clear, should the scaling loop in the above pseudish-code be outside the main loop?

I hope the second bit of the code is clear? I think the question reduces to whether the area under the curve along each dimension is 1 or the whole curve (in all dimensions) has an area of 1 under it?

Thanks,

Luca
 
Last edited by a moderator:
Mathematics news on Phys.org
Yes, the sum of all rescaled values in the entire kernel should be 1. That way, if you apply the kernel to a constant image, it's unchanged. If you do smoothing along each axis separately, the sum of kernel values in each 1-D kernel should be 1.

It's not 100% clear what's going on in that code. Depends on the way kernel values are computed. It is quite possible that kernel values don't add to 1 simply because of the windowing and the discretization: you'd get the right answer if you integrated from -infinity to +infinity, but instead you're summing from -radius to radius-1.
 
Thanks for the reply. I think I understand now. The isotropic Gaussian smoothing reduces to smoothing separately by Gaussian kernels in each of the dimensions and this is why the code was summing up the kernel coefficients for each axes and normalizing by that.

I guess if our discrete kernel is wide enough (3 standard deviations or moe), we do not need to bother with that as the sum will be sufficiently close to unity.

Thanks,

Luca
 
The normalization factor in your link (1/\sqrt{2\pi}\sigma) is only universally valid for the continuous kernel. It is a convenient curious fact that the same factor also works for the discrete kernel as long as sigma>=1:

\sum_{n=-\infty}^\infty G(n) = 1

But for sigma<1 and for other kernels, that is no longer the case.
 
That is indeed something that is not immediately clear to me.

I can appreciate that when sampling the continuous function to get the discrete values, the sum of the values will not be 1. However, I do not see anything else besides this...

How did you figure out the normalization factor and its special relationship with sigma = 1...?

Thanks for your replies. Much appreciated.

Luca
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
0
Views
992
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K