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

I am in Week1 in Convolutional Neural Network Course.

I’m seeing this pattern that the edge detection filters elements add up to 0 and blurring or smoothing filters add up to 1.

Why is the rationale behind this? I’m curious to know.

Thanks a lot :slight_smile:

Hi bardh,

You can have a look here. I hope this clarifies the difference between smoothing and edge detection filters.

Hello @reinoudbosch, thank you for taking the time to answer. However, the link you provided is redirecting me to https://community.deeplearning.ai/

Did you mean to redirect me somewhere else?

Appreciate it :slight_smile:

Hi bardh,

Thanks for your notice. I updated the link. The course as a whole may also be interesting:

Hello @reinoudbosch

I checked out the link you provided. It only said that a smoothing filter has a mean of 1, but nothing more (just like in the image provided down below).

I also viewed the lecture on Edge Detection (Thanks for sharing the course link!) and they were a bit technical, but I could follow through. However, it still remains unclear to me as to why is this general pattern of why the sum of all elements in an edge detection filter is 0, and the smoothing filter is 1.

I read something in an article saying that it has to do with edge detection being a high-pass filter, meaning eliminating the noise (small variations) in the image, but not why they sum up to 0.

Hi bardh,

Thanks for your response. The reason I shared the first link is because I feel it shows quite well what smoothing and edge detection filters are doing.

My interpretation about why edge detection filters sum up to zero is that while increasing contrast you don’t want to distort overall values more than necessary. With a smoothing filter you cannot add up to zero because then you do not get a smoothing effect. So instead a value of 1 is used that retains relative values. As you can see in the lecture this may be a simple average or a weighted average. The lecture also shows how different values for sigma can be used to limit unnecessary distortion and provide focus. These are my two cents. If you find out more just post it here!

1 Like