SciPy

scipy.ndimage.prewitt

scipy.ndimage.prewitt(input, axis=-1, output=None, mode='reflect', cval=0.0)[source]

Calculate a Prewitt filter.

Parameters:

input : array_like

Input array to filter.

axis : int, optional

The axis of input along which to calculate. Default is -1.

output : array, optional

The output parameter passes an array in which to store the filter output.

mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional

The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’. Default is ‘reflect’

cval : scalar, optional

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

Examples

>>> from scipy import ndimage, misc
>>> import matplotlib.pyplot as plt
>>> ascent = misc.ascent()
>>> result = ndimage.prewitt(ascent)
>>> plt.gray()  # show the filtered result in grayscale
>>> plt.imshow(result)

(Source code)

../_images/scipy-ndimage-prewitt-1.png