[Numpy-discussion] Sobel question
Peter Verveer
verveer at embl-heidelberg.de
Sat Nov 13 08:17:01 CST 2004
Hi Bob,
> I think it will be, especially the segmentation and object
> measurements.
Let me know how that goes, I would be interested to hear were the weak
points are especially with these functions, which are not completely
fleshed out. Let me know if something is missing or not working quite
right. Also comments on the manual are welcome...
> I'm apparently running into a learing curve so please bear with me.
No worry, all feedback is welcome.
>
>> The Sobel filter is always a derivative along a single direction. A
>> negative value is used to specifiy an axis relative to the rank of
>> the array, so for a 2D array, axis=-1 is equivalent to axis=1, ...
>
> In my tests axis=-1 and axis=1 produce different results. See code
> below. And of course when I scale the results to a range of 0 to 255
> and convert to an image, the image is different also. Is this a bug or
> am I missing something?
That was indeed a bug, negative axis arguments do not work properly
(also with the prewitt function) I fixed that in the CVS version today.
>
>> If you want a gradient magnitude using Sobel derivatives, you can use
>> the generic_gradient_magnitude() function.
>
> This looks good except I can't get it to work. Can you show me a
> little code fragment? I've gotten the following code to work but your
> way might be faster.
>
> vert = ND.sobel(a, 0)
> horz = ND.sobel(a, 1)
> mag = numarray.sqrt((horz * horz) + (vert * vert))
mag = ND.generic_gradient_magnitude(a, derivative = ND.sobel)
I have updated the manual (in CVS) with some examples. I also decided
to change the order of the arguments of both the generic_laplace and
generic_gradient_magnitude functions, so with the latest CVS version
you could now also say:
mag = ND.generic_gradient_magnitude(a, ND.sobel)
Cheers, Peter
More information about the Numpy-discussion
mailing list