[Numpy-discussion] Sobel question
verveer at embl-heidelberg.de
Wed Nov 10 16:15:06 CST 2004
> I recently started playing with numarray and especially nd_image for
> processing grayscale and RGB images. nd_image looks very interesting
> and I'm looking forward to checking.
Thanks for your interest! I hope it is useful for you...
> My question deals with the axis parameter of the Sobel filter. What
> does the function return when axis=-1?
> I figured out that when axis=0, the function returns the vertical
> gradient component and when axis=1 the horizontal gradient component.
> Since -1 is the default I expected that it would return the gradient
> magnitude (sqrt(x*x + y*y)) but that's not the case.
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, and axis=-2
is equivalent to axis=0. For a 3D array, axis=-1 is equivalent to
axis=2. This convention is (or should be) followed by all numarray
functions that specify an axis.
If you want a gradient magnitude using Sobel derivatives, you can use
the generic_gradient_magnitude() function.
More information about the Numpy-discussion