2
$\begingroup$

I am trying to figure out the answer to the following question: enter image description here

As I understand it, I am supposed to apply the algorithm only on this part of the image

[2,5,6]
[4,2,7]
[1,3,5]

My question is how to apply the two gradients for x and y respectively on this part of the image? Thank you in advance!

$\endgroup$
2
$\begingroup$

I was able to answer my question after doing more research. The key is to slide the 3x3 kernel and perform Gx and Gy (gradient for the x and y directions) and calculate the output image values. For example, to calculate the output image top left value -

[x - -]
[- - -]
[- - -]

we have to calculate both gradients (x and y)->

Gx

[-1 0 1]
[-1 0 1]
[-1 0 1]

we take the first chunk of the original image (e.g. sliding the kernel over the top values of the input image)

[1 2 4]
[5 2 5]
[5 4 2]

Gx = 4+5+2 - 1-5-5 = 0

Gy = 5+4+2 - 1-2-4 = 4 We take the absolute values of both and sum them so |4| + |0| = 4

And this is the first top value of the output image.

[4 - -]
[- - -]
[- - -]

The same way we calculate the rest. I hope that will help anyone else facing the same problem.

$\endgroup$

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.