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...
Lets say you want to calculate the gradient in the horizontal direction for one cell right next to the central area of increased grey value (I marked the pixel in grey), Then you multiply the values in your operator (small indicated numbers) by adjacency with the grey values in the adjacent pixels (encircled in green) and sum them up:
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$
So the gradient in the horizontal direction at that pixel is -150. (If you use that particular operator)