# How can I compute the gradient of the noiseless image given by the compass operator?

I need to generate an image with 11x11 pixels having in the center of the image a square of 5x5 pixels, with the gray level of the background 0 and the gray level of the square is 50. I need to compute the gradient of the image given by the compass operator, taking into account that the image is not noisy(simple derivation). I don't know how to compute this, I don't know what it's my image function, I only have some formulas that are ,, useful", but very hard to apply. I've tried to apply the Sobel operator and I got 0, I think the result it's wrong, but since the image, it's noiseless the computation will be simplified if I'm using this formula, but I don't know where to start from...

• Welcome to Scicomp! If I see it correctly, then the operators are -not- to be applied like a matrix-vector product, but by adjacency.So when you want to measure the gradient for a given cell in east direction, you multiply the values in the adjacent cells by the values given in your operator and sum them up. For some of the evaluations you will actually find zeros! Jan 8 at 13:29
• @MPIchael for all I got 0,and I don't know if it's correctly or not... Jan 9 at 12:45
• Can you use MathJax for typing equations? Jan 18 at 15:05

In this example that would give you: $$((-1*50) + (-1*50) +(-1*50) + (0*0) + (0*0) + (0*0) + (1*0)+(1*0)+(1*0))=-150$$