## Re: [Matplotlib-users] Displaying the gradient of an image

 Re: [Matplotlib-users] Displaying the gradient of an image From: Mathieu Dubois - 2010-06-29 14:28:19 ```Hello, I finally found the solution. It's as simple as: figure(); imshow(img); pylab.quiver(U, V, units='x'); Mathieu ```

### Thread view

 [Matplotlib-users] Displaying the gradient of an image From: Mathieu Dubois - 2010-06-29 09:44:33 ```Hello, I'm playing with some image processing algorithm (HOG descriptor) and I'm a bit lost. I am a newbie in image processing (especially in python). I have computed the vertical and horizontal gradients of an image (convolution with [-1, 0, 1] on the 0 and 1 axis respectively). After that I computed the gradient' magnitude (sqrt(horizontal_gradient**2 + vertical_gradient**2)) and orientation (arctan2(vertical_gradient, horizontal_gradient)). Now I would like to display the original image with the gradient vector. The quiver() function allows to plot vector fields and it's pretty easy to convert the gradient' magnitude and orientation into U and V (U =grad_mag*cos(grad_orientation), V = grad_mag*sin(grad_orientation)) but I cannot figure out how to display the image and the gradient with the right orientation. Can anyone help? Thanks in advance, Mathieu ```
 Re: [Matplotlib-users] Displaying the gradient of an image From: Mathieu Dubois - 2010-06-29 14:28:19 ```Hello, I finally found the solution. It's as simple as: figure(); imshow(img); pylab.quiver(U, V, units='x'); Mathieu ```
 Re: [Matplotlib-users] Displaying the gradient of an image From: Thomas Lecocq - 2010-06-29 19:21:08 Attachments: Message as HTML ```Hi, You can also use Numpy.gradient to compute the gradient , if e.g. your dx and dy aren't the same. Cheers, Thom ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** > Date: Tue, 29 Jun 2010 16:28:11 +0200 > From: mathieu.dubois@... > To: matplotlib-users@... > Subject: Re: [Matplotlib-users] Displaying the gradient of an image > > Hello, > > I finally found the solution. It's as simple as: > figure(); > imshow(img); > pylab.quiver(U, V, units='x'); > > Mathieu > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```

## Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks