1
$\begingroup$

When I compute a gaussian kernel for image blurring should I normalize the 1D vectors? Because when I apply the raw values sometimes the image gets lighter or darker. The function I'm using is $f(x) = \frac{1}{\sqrt{2\pi}\sigma}e^{\frac{-x^2}{2\sigma^2}}$ or the 2D function. So, should I just apply the results using cross correlation/convolution or should I normalize first?

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to cs.stackexchange! Have you tried to see what happens when you normalize the 1-D vectors? $f(x)$ is a one-dimensional function, but your image is 2-D. What are you feeding this function? The distance to the blurred pixel? Can you elaborate on how you compute the new colours? $\endgroup$ May 28, 2016 at 18:47
  • $\begingroup$ The input is the distance from the mean, but like @EvilJS replied the sum is greater or less than 1 and it makes the image lighter or darker. $\endgroup$ May 30, 2016 at 14:33

1 Answer 1

0
$\begingroup$

Your function is used to compute 2D kernel, which you should normalize, otherwise if the sum of used weights is higher than $1$ your image gets lighter, when it is smaller it gets darker. You should not normalize vectors, because you apply 2D kernel, so normalized 1D vectors will not help.

The operation that you perform is convolution, not correlation, which in common meaning would try to measure how similar is the part of image to given kernel.

$\endgroup$
2
  • $\begingroup$ Thanks, I tought that a gaussian kernel would give a sum of 1 $\endgroup$ May 30, 2016 at 14:35
  • $\begingroup$ Yes it does, in 1D case, but then you take it to 2D and make symmetric mirror. There are probably neglible round off errors, but it also adds up to value not equal $1$. $\endgroup$
    – Evil
    May 30, 2016 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.