This is more a theoretical question than practical, and I'm referring to 3x3 convolution kernels with online demo and the first comment after it.
I have a raster elevation model and want to turn it into slope/gradient using convolution. The article gives me kernels to use for horizontal gradient detection and vertical gradient detection.
I use them and so have two convoluted DEMs; one with horizontal gradient and one with vertical. To get the full effect I must merge them together.
The comment underneath the article suggests that to merge these I should use the equation:
pixel = SQRT(pixel_convolved_along_x ^ 2 + pixel_convolved_along_y ^ 2)
I do that and the result looks good. In fact I compare it to a slope generated directly by a slope-creation tool and the results look identical.
So I have a process that works and a result I'm happy with - I just don't understand why that equation is used to merge cells. It looks like Pythagoras to me (a=sqrt(b^2+c^2)).
So why that and why not simply average the two cells using (a+b)/2?
Can anyone help me understand this?