SciPy

scipy.ndimage.generic_gradient_magnitude

scipy.ndimage.generic_gradient_magnitude(input, derivative, output=None, mode='reflect', cval=0.0, extra_arguments=(), extra_keywords=None)[source]

Gradient magnitude using a provided gradient function.

Parameters:

input : array_like

Input array to filter.

derivative : callable

Callable with the following signature:

derivative(input, axis, output, mode, cval,
           *extra_arguments, **extra_keywords)

See extra_arguments, extra_keywords below. derivative can assume that input and output are ndarrays. Note that the output from derivative is modified inplace; be careful to copy important inputs before returning them.

output : array, optional

The output parameter passes an array in which to store the filter output. Output array should have different name as compared to input array to avoid aliasing errors.

mode : str or sequence, optional

The mode parameter determines how the array borders are handled. Valid modes are {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}. cval is the value used when mode is equal to ‘constant’. A list of modes with length equal to the number of axes can be provided to specify different modes for different axes. Default is ‘reflect’

cval : scalar, optional

Value to fill past edges of input if mode is ‘constant’. Default is 0.0

extra_keywords : dict, optional

dict of extra keyword arguments to pass to passed function

extra_arguments : sequence, optional

Sequence of extra positional arguments to pass to passed function