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.

1 Answers 1