2
$\begingroup$

I'm trying to make a gradient flow for an image. For a test I made a small image 3x3 pixels with a black pixel in the middle.

I found how to compute the direction of the gradient for one point given by coordinates (x,y)

$$\varphi (x,y)=arctan\frac{G_{y}}{G_{x}}$$

Using Sobel operator I got these gradients: $$G_x = \begin{bmatrix} 255 & 0 & -255 \\ 510 & 0& -510\\ 255 & 0 & -255 \end{bmatrix}, G_y = \begin{bmatrix} 255 & 510 & 255 \\ 0 & 0& 0\\ -255 & -510 & -255 \end{bmatrix}$$

I also computed the gradient magnitude:

$$\left \| G\right \|^{2} = \begin{bmatrix} 130050.00 & 260100.00 & 130050.00\\ 260100.00& 0 & 260100.00\\ 130050.00& 260100.00 &130050.00 \end{bmatrix}$$

but I have no idea how to make an image with the arrows representing the direction of the gradient. Could anyone please explain me how to do it? Thanks.

$\endgroup$
1
$\begingroup$

No need for the $\arctan$ or $|| \cdot ||^2$. The coordinates of your arrow are directly given by $G_x$ and $G_y$. Also the expression for the square nom is a bit suspicious since it is not simply a convolution.

$\endgroup$
  • $\begingroup$ Could you please give me an example of the arrow's coordinates (or angle) for the first pixel? I'm sorry, but I still don't understand, because I have the picture 3x3, but values are much greater (255 and 510). $\endgroup$ – DropDropped Dec 8 '12 at 20:52

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.