I am studying pyramids (expanding and reducing) and I am a newbie. Why should the sum of the convolution mask be one when we are using gaussian distribution?

According to When should the sum of all elements of a gaussian kernel be zero? and Why is sum of values of an edge detection filter zero? it should be zero not one.

I am confused. Any precise explanation is really appreciated.

  • $\begingroup$ Could you please mark my answer? $\endgroup$ – Royi Mar 20 at 8:23

When you're trying to create a blurring kernel (namely a weighted mean of the data) you keep the mask sum as one.
This preserves the mean of the filtered image (think about the DFT, if the sum mask is 1 its DC gain is 1 which means it keeps the sum of the image which means it keeps the mean value of the image.)

When you're trying to apply a high pass filter you want to have gain of zero at the DC coefficient.
This is done by having the sum of the mask as zero (same reason as above.)

  • $\begingroup$ @JRE, Thank you for the edit. $\endgroup$ – Royi Nov 18 '19 at 13:23

Standard linear filtering on regularly-sampled data acts "separately" in each cartesian direction: along rows, columns (and time, depth or wavelength for 3D data, like video, tomography or multispectral images). If you look at a given 2D filter (applies to 3D too) in each direction $d$, you can feel the nature of the filter.

If the coefficients sum to one, then a constant input signal turns into a constant output signal of the same amplitude. Constant signal are low frequency, so by continuity, you expect a low-pass behavior. If the coefficients sum to zero, then a constant signal turns to zero, so you can imagine a low-cut behavior.

In a dual manner, if the sum of coefficients with alternating signs ($c_1,c_2,\ldots,c_n \to -c_1,c_2,\ldots,(-1)^n c_n$) is one, then you can expect a high-pass behavior. If they sum to zero, then a high-cut effect is plausible.

One can interpret this as integrating in one direction, differentiating in the other. You can also look at the sums not only in the horizontal and vertical directions, but along diagonal or other slopes.

So keeping with linear filters, many useful filters in image processing either:

  1. Sum to 1 in both directions (and often sum to a small value with alternating signs): they are mostly blurring kernels
  2. Sum to 1 in one direction, to 0 in the other: they are directional filters, detecting edges along the $0$-sum direction

Some filters, like the Laplacian mask, sum to zeros by combining both directions.

  • $\begingroup$ @JRE, Thank you for the edit. $\endgroup$ – Laurent Duval Nov 18 '19 at 15:03
  • 1
    $\begingroup$ What book should I read to learn it as you learned? can you please direct me to the source to understand it as deep as yours? $\endgroup$ – Alex Sep 16 '20 at 1:23
  • 1
    $\begingroup$ I learnt this by combining different sources, especially as filters in 1D and 2D are often taught in a different manner. Then I combined the information for the lectures I have been giving. Nothing fully written on my side unfortunately. I'll try to dig in old books $\endgroup$ – Laurent Duval Sep 16 '20 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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