Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
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). –  DropDropped Dec 8 '12 at 20:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.