Why the sum of all the elements in Edge detection kernel is zero?

3.3k views Asked by At

For example, In Sobel operator, the Sobel Kernel,

Gx = [-1 0 +1;
      -2 0 +2; 
      -1 0 +1];

Gy = [+1 +2 +1;
       0  0  0; 
      -1 -2 -1];

Why the sum is zero? Is there any specific reason?

2

There are 2 answers

1
Steffen On BEST ANSWER

An edge kernel is a highpass filter. Low frequencies shall be supressed, high frequencies shall pass such a filter. Edges are parts of an image with a high change of signal (gray value) and so high frequencies.

If you design such a filter in frequency domain, it will have zeros at low frequencies and bigger values at higher frequencies. When transforming this into spatial domain (to get a kernel like you described), this will always result in a kernel, where the sum is zero.

2
Ian Bruce On

If the sum of the weights were not zero, then a region of the image that was completely uniform would be found to have a non-zero gradient. This is contrary to the definition of what a gradient is.