0
$\begingroup$

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...enter image description here

enter image description here

enter image description here

$\endgroup$
3
  • $\begingroup$ 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! $\endgroup$ – MPIchael Jan 8 at 13:29
  • $\begingroup$ @MPIchael for all I got 0,and I don't know if it's correctly or not... $\endgroup$ – Robinson Chera Jan 9 at 12:45
  • $\begingroup$ Can you use MathJax for typing equations? $\endgroup$ – nicoguaro Jan 18 at 15:05
0
$\begingroup$

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:

Example pixel for horizontal gradient

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)

$\endgroup$
3
  • $\begingroup$ Thanks, I've calculated it but the final result for the gradient it's 0. Is this wrong? $\endgroup$ – Robinson Chera Jan 11 at 11:54
  • $\begingroup$ Yes, that is wrong. There is gradient in the image $\endgroup$ – MPIchael Jan 11 at 12:09
  • $\begingroup$ so basically what I've done it's totally wrong...I've got a matrix like this: [0 -50 -50 0 0 0 50 0], [0 -150 -150 0 0 0 150 0], [0 -200 -200 0 0 0 200 0], [0 -200 -200 0 0 0 200 0], [0 -200 -200 0 0 0 200 0], [0,-150,-150 0 0 0 150 0], [0 -50 -50 0 0 0 50 0 0], and my final result was 0, that's what I was trying to say... $\endgroup$ – Robinson Chera Jan 11 at 12:19

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.