#### Previous topic

scipy.ndimage.rank_filter

#### Next topic

scipy.ndimage.uniform_filter

# scipy.ndimage.sobel

`scipy.ndimage.``sobel`(input, axis=-1, output=None, mode='reflect', cval=0.0)

  Calculate a Sobel 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. 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

  Examples

      >>> from scipy import ndimage, misc
      >>> import matplotlib.pyplot as plt
      >>> fig = plt.figure()
      >>> plt.gray()  # show the filtered result in grayscale
      >>> ax1 = fig.add_subplot(121)  # left side
      >>> ax2 = fig.add_subplot(122)  # right side
      >>> ascent = misc.ascent()
      >>> result = ndimage.sobel(ascent)
      >>> ax1.imshow(ascent)
      >>> ax2.imshow(result)
      >>> plt.show()

  (Source code)