[SciPy-user] Sobel filter, magnitude and gradient direction

Rick Wagner rwagner at physics.ucsd.edu
Fri Mar 21 16:22:10 EDT 2008


Hi Daniele,

> import Image
> import scipy
> import scipy.ndimage
>
> data = Image.open("image.jpg")
> image_magnitude = scipy.ndimage.filters.generic_gradient_magnitude 
> (data, scipy.ndimage.filters.sobel)
> output = Image.fromstring("RGB",(320,210),image_magnitude.tostring())
> output.save("imagem.jpg","JPEG")

You might want to plot the resulting array before saving the data, to  
make sure that it's the filter, and not the data. You can do this  
using matplotlib's imshow command.

--Rick

http://www.scipy.org/Cookbook/Matplotlib

------------------------------------------------------------------------ 
-
Rick Wagner, Graduate Student Researcher
UCSD Physics
9500 Gilman Drive
La Jolla, CA  92093-0424
Email:  rwagner at physics.ucsd.edu
WWW:    http://lca.ucsd.edu/projects/rpwagner
(858) 822-4784 Phone
------------------------------------------------------------------------ 
-
Measuring programming progress by lines of code is
like measuring aircraft building progress by weight.
--Bill Gates
------------------------------------------------------------------------ 
-



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080321/538a21b8/attachment.html>


More information about the SciPy-User mailing list