Date: Aug 15, 2013 1:55 PM
Author: amira ali
Subject: Re: plot gradient  vectors over image

"Josh Meyer" <jmeyer@mathworks.com> wrote in message <kuikuh$2f7$1@newscl01ah.mathworks.com>...
> >"amira ali" <amiraali2005@gmail.com> wrote in message
> >news:kui9c3$7p6$1@newscl01ah.mathworks.com...
> > please
> > how can i plot gradient vectors over image using this function
> >
> > [Gx,Gy] = gradient2( I )
> > % Gx - [hxwxk] x-gradient (horizontal)
> > % Gy - [hxwxk] y-gradient (vertical)
> >
> > thanks

>
> I assume you mean "gradient" and not "gradient2"
>
> At any rate, it sounds like you want the quiver function:
> "quiver(x,y,u,v) plots velocity vectors as arrows with components (u,v) at
> the points (x,y)."
>
> More info here: http://www.mathworks.com/help/matlab/ref/quiver.html
>

is this code is correct
I = imread('img1.jpeg');
[gx,gy] = gradient(double(rgb2gray(I)));
g = abs(gx) + abs(gy);
figure;
imshow(g,'InitialMagnification','fit')
hold on;
quiver(abs(gx),abs(gy));