# why the sum of masks should be one?

I am studying pyramids (expanding and reducing) and I am a newbie. Why sum of the convolution mask should 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.

• Votes and best answer validation are required – Laurent Duval Jul 28 at 11:55

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 it's 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 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).

Standard linear filtering on data acts "separately" in each 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 coeficients sum to one, then a constant signal turns into a constant signal of the same amplitude. Constant signal are low frequency, so by continuity, you expect a low-pass behavior. If the coeficients sum to zero, then a constant signal turns to zero, so you can image a low-cut behavior.

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 linearfilters, many useful filters in ipmage 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 Lapcian sum to zeros by combining both directions.