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

Daniele Di Mauro daniele.dm at gmail.com
Fri Mar 21 16:09:52 EDT 2008


Hi folks,
it's the first time i write on this mailing list, i hope i chose the right
one. Yesterday i started a small project for university and i need some
help:
I've to calculate the sobel edge magnitude and gradient direction of an
image, and i haven't undestood if i'm doing right, btw this is the code:

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")

I've not look at the gradient direction part yet, but the result it's quite
strange, i cannot see edges. I tried also this:

import Image
import scipy
import scipy.ndimage

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

but it doesn't convice me either coz it looks quite different from the
result of gimp built-in version or using gimp matrix convolution. Thanx in
advance for your help

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


More information about the SciPy-User mailing list