Package stsci :: Package ndimage :: Module filters
[hide private]
[frames] | no frames]

Module filters

source code

Functions [hide private]
 
correlate1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)
Calculate a one-dimensional correlation along the given axis.
source code
 
convolve1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)
Calculate a one-dimensional convolution along the given axis.
source code
 
gaussian_filter1d(input, sigma, axis=-1, order=0, output=None, mode='reflect', cval=0.0)
One-dimensional Gaussian filter.
source code
 
gaussian_filter(input, sigma, order=0, output=None, mode='reflect', cval=0.0)
Multi-dimensional Gaussian filter.
source code
 
prewitt(input, axis=-1, output=None, mode='reflect', cval=0.0)
Calculate a Prewitt filter.
source code
 
sobel(input, axis=-1, output=None, mode='reflect', cval=0.0)
Calculate a Sobel filter.
source code
 
generic_laplace(input, derivative2, output=None, mode='reflect', cval=0.0, extra_arguments=(), extra_keywords=None)
Calculate a multidimensional laplace filter using the provided second derivative function.
source code
 
laplace(input, output=None, mode='reflect', cval=0.0)
Calculate a multidimensional laplace filter using an estimation for the second derivative based on differences.
source code
 
gaussian_laplace(input, sigma, output=None, mode='reflect', cval=0.0)
Calculate a multidimensional laplace filter using gaussian second derivatives.
source code
 
generic_gradient_magnitude(input, derivative, output=None, mode='reflect', cval=0.0, extra_arguments=(), extra_keywords=None)
Calculate a gradient magnitude using the provided function for the gradient.
source code
 
gaussian_gradient_magnitude(input, sigma, output=None, mode='reflect', cval=0.0)
Calculate a multidimensional gradient magnitude using gaussian derivatives.
source code
 
_correlate_or_convolve(input, weights, output, mode, cval, origin, convolution) source code
 
correlate(input, weights, output=None, mode='reflect', cval=0.0, origin=0)
Multi-dimensional correlation.
source code
 
convolve(input, weights, output=None, mode='reflect', cval=0.0, origin=0)
Multi-dimensional convolution.
source code
 
uniform_filter1d(input, size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)
Calculate a one-dimensional uniform filter along the given axis.
source code
 
uniform_filter(input, size=3, output=None, mode='reflect', cval=0.0, origin=0)
Multi-dimensional uniform filter.
source code
 
minimum_filter1d(input, size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)
Calculate a one-dimensional minimum filter along the given axis.
source code
 
maximum_filter1d(input, size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)
Calculate a one-dimensional maximum filter along the given axis.
source code
 
_min_or_max_filter(input, size, footprint, structure, output, mode, cval, origin, minimum) source code
 
minimum_filter(input, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)
Calculates a multi-dimensional minimum filter.
source code
 
maximum_filter(input, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)
Calculates a multi-dimensional maximum filter.
source code
 
_rank_filter(input, rank, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0, operation='rank') source code
 
rank_filter(input, rank, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)
Calculates a multi-dimensional rank filter.
source code
 
median_filter(input, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)
Calculates a multi-dimensional median filter.
source code
 
percentile_filter(input, percentile, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)
Calculates a multi-dimensional percentile filter.
source code
 
generic_filter1d(input, function, filter_size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0, extra_arguments=(), extra_keywords=None)
Calculate a one-dimensional filter along the given axis.
source code
 
generic_filter(input, function, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0, extra_arguments=(), extra_keywords=None)
Calculates a multi-dimensional filter using the given function.
source code
Variables [hide private]
  _input_doc = 'input : array-like\n input array to filter'
  _axis_doc = 'axis : integer, optional\n axis of ``input`` a...
  _output_doc = 'output : array, optional\n The ``output`` pa...
  _size_foot_doc = 'size : scalar or tuple, optional\n See fo...
  _mode_doc = 'mode : {\'reflect\',\'constant\',\'nearest\',\'mi...
  _cval_doc = 'cval : scalar, optional\n Value to fill past e...
  _origin_doc = 'origin : scalar, optional\nThe ``origin`` param...
  _extra_arguments_doc = 'extra_arguments : sequence, optional\n...
  _extra_keywords_doc = 'extra_keywords : dict, optional\n di...
  docdict = {'axis': 'axis : integer, optional\n axis of ``in...
  __package__ = 'stsci.ndimage'

Imports: math, numpy, _ni_support, _nd_image, doccer, docfiller


Function Details [hide private]

correlate1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculate a one-dimensional correlation along the given axis.

The lines of the array along the given axis are correlated with the
given weights.

Parameters
----------
input : array-like
    input array to filter
weights : array
    one-dimensional sequence of numbers
axis : integer, optional
    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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

convolve1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculate a one-dimensional convolution along the given axis.

The lines of the array along the given axis are convolved with the
given weights.

Parameters
----------
input : array-like
    input array to filter
weights : ndarray
    one-dimensional sequence of numbers
axis : integer, optional
    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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

gaussian_filter1d(input, sigma, axis=-1, order=0, output=None, mode='reflect', cval=0.0)

source code 
One-dimensional Gaussian filter.

Parameters
----------
input : array-like
    input array to filter
sigma : scalar
    standard deviation for Gaussian kernel
axis : integer, optional
    axis of ``input`` along which to calculate. Default is -1
order : {0, 1, 2, 3}, optional
    An order of 0 corresponds to convolution with a Gaussian
    kernel. An order of 1, 2, or 3 corresponds to convolution with
    the first, second or third derivatives of a Gaussian. Higher
    order derivatives are not implemented
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

Decorators:
  • @docfiller

gaussian_filter(input, sigma, order=0, output=None, mode='reflect', cval=0.0)

source code 
Multi-dimensional Gaussian filter.

Parameters
----------
input : array-like
    input array to filter
sigma : scalar or sequence of scalars
    standard deviation for Gaussian kernel. The standard
    deviations of the Gaussian filter are given for each axis as a
    sequence, or as a single number, in which case it is equal for
    all axes.
order : {0, 1, 2, 3} or sequence from same set, optional
    The order of the filter along each axis is given as a sequence
    of integers, or as a single number.  An order of 0 corresponds
    to convolution with a Gaussian kernel. An order of 1, 2, or 3
    corresponds to convolution with the first, second or third
    derivatives of a Gaussian. Higher order derivatives are not
    implemented
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

Notes
-----
The multi-dimensional filter is implemented as a sequence of
one-dimensional convolution filters. The intermediate arrays are
stored in the same data type as the output. Therefore, for output
types with a limited precision, the results may be imprecise
because intermediate results may be stored with insufficient
precision.

Decorators:
  • @docfiller

prewitt(input, axis=-1, output=None, mode='reflect', cval=0.0)

source code 
Calculate a Prewitt filter.

Parameters
----------
input : array-like
    input array to filter
axis : integer, optional
    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

Decorators:
  • @docfiller

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

source code 
Calculate a Sobel filter.

Parameters
----------
input : array-like
    input array to filter
axis : integer, optional
    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

Decorators:
  • @docfiller

generic_laplace(input, derivative2, output=None, mode='reflect', cval=0.0, extra_arguments=(), extra_keywords=None)

source code 
Calculate a multidimensional laplace filter using the provided
second derivative function.

Parameters
----------
input : array-like
    input array to filter
derivative2 : callable
    Callable with the following signature::
        derivative2(input, axis, output, mode, cval,
                    *extra_arguments, **extra_keywords)
    See ``extra_arguments``, ``extra_keywords`` below
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
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

Decorators:
  • @docfiller

laplace(input, output=None, mode='reflect', cval=0.0)

source code 
Calculate a multidimensional laplace filter using an estimation
for the second derivative based on differences.

Parameters
----------
input : array-like
    input array to filter
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

Decorators:
  • @docfiller

gaussian_laplace(input, sigma, output=None, mode='reflect', cval=0.0)

source code 
Calculate a multidimensional laplace filter using gaussian
second derivatives.

Parameters
----------
input : array-like
    input array to filter
sigma : scalar or sequence of scalars
    The standard deviations of the Gaussian filter are given for
    each axis as a sequence, or as a single number, in which case
    it is equal for all axes..
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

Decorators:
  • @docfiller

generic_gradient_magnitude(input, derivative, output=None, mode='reflect', cval=0.0, extra_arguments=(), extra_keywords=None)

source code 
Calculate a gradient magnitude using the provided function for
the gradient.

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.
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
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

Decorators:
  • @docfiller

gaussian_gradient_magnitude(input, sigma, output=None, mode='reflect', cval=0.0)

source code 
Calculate a multidimensional gradient magnitude using gaussian
derivatives.

Parameters
----------
input : array-like
    input array to filter
sigma : scalar or sequence of scalars
    The standard deviations of the Gaussian filter are given for
    each axis as a sequence, or as a single number, in which case
    it is equal for all axes..
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

Decorators:
  • @docfiller

correlate(input, weights, output=None, mode='reflect', cval=0.0, origin=0)

source code 

Multi-dimensional correlation.

The array is correlated with the given kernel.

Parameters
----------
input : array-like
    input array to filter
weights : ndarray
    array of weights, same number of dimensions as input
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
origin : scalar, optional
    The ``origin`` parameter controls the placement of the filter.
    Default 0

See Also
--------
convolve : Convolve an image with a kernel.

Decorators:
  • @docfiller

convolve(input, weights, output=None, mode='reflect', cval=0.0, origin=0)

source code 

Multi-dimensional convolution.

The array is convolved with the given kernel.

Parameters
----------
input : array_like
    Input array to filter.
weights : array_like
    Array of weights, same number of dimensions as input
output : ndarray, 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. For 'constant' mode, values beyond borders are set to be
    `cval`. Default is 'reflect'.
cval : scalar, optional
    Value to fill past edges of input if `mode` is 'constant'. Default
    is 0.0
origin : scalar, optional
    The `origin` parameter controls the placement of the filter.
    Default is 0.

Returns
-------
result : ndarray
    The result of convolution of `input` with `weights`.

See Also
--------
correlate : Correlate an image with a kernel.

Notes
-----
Each value in result is :math:`C_i = \sum_j{I_{i+j-k} W_j}`, where
W is the `weights` kernel,
j is the n-D spatial index over :math:`W`,
I is the `input` and k is the coordinate of the center of
W, specified by `origin` in the input parameters.

Examples
--------
Perhaps the simplest case to understand is ``mode='constant', cval=0.0``,
because in this case borders (i.e. where the `weights` kernel, centered
on any one value, extends beyond an edge of `input`.

>>> a = np.array([[1, 2, 0, 0],
....    [5, 3, 0, 4],
....    [0, 0, 0, 7],
....    [9, 3, 0, 0]])
>>> b = np.array([[1,1,1],[1,1,0],[1,0,0]])
>>> from stsci import ndimage
>>> ndimage.convolve(a, k, mode='constant', cval=0.0)
array([[11, 10,  7,  4],
       [10,  3, 11, 11],
       [15, 12, 14,  7],
       [12,  3,  7,  0]])

Setting ``cval=1.0`` is equivalent to padding the outer edge of `input`
with 1.0's (and then extracting only the original region of the result).

>>> ndimage.convolve(a, k, mode='constant', cval=1.0)
array([[13, 11,  8,  7],
       [11,  3, 11, 14],
       [16, 12, 14, 10],
       [15,  6, 10,  5]])

With ``mode='reflect'`` (the default), outer values are reflected at the
edge of `input` to fill in missing values.

>>> b = np.array([[2, 0, 0],
                  [1, 0, 0],
                  [0, 0, 0]])
>>> k = np.array([[0,1,0],[0,1,0],[0,1,0]])
array([[5, 0, 0],
       [3, 0, 0],
       [1, 0, 0]])

This includes diagonally at the corners.

>>> k = np.array([[1,0,0],[0,1,0],[0,0,1]])
>>> ndimage.convolve(b, k)
array([[4, 2, 0],
       [3, 2, 0],
       [1, 1, 0]])

With ``mode='nearest'``, the single nearest value in to an edge in
`input` is repeated as many times as needed to match the overlapping
`weights`.

>>> c = np.array([[2, 0, 1],
                  [1, 0, 0],
                  [0, 0, 0]])
>>> k = np.array([[0, 1, 0],
                  [0, 1, 0],
                  [0, 1, 0],
                  [0, 1, 0],
                  [0, 1, 0]])
>>> ndimage.convolve(c, k, mode='nearest')
array([[7, 0, 3],
       [5, 0, 2],
       [3, 0, 1]])

Decorators:
  • @docfiller

uniform_filter1d(input, size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculate a one-dimensional uniform filter along the given axis.

The lines of the array along the given axis are filtered with a
uniform filter of given size.

Parameters
----------
input : array-like
    input array to filter
size : integer
    length of uniform filter
axis : integer, optional
    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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

uniform_filter(input, size=3, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Multi-dimensional uniform filter.

Parameters
----------
input : array-like
    input array to filter
size : int or sequence of ints
    The sizes of the uniform filter are given for each axis as a
    sequence, or as a single number, in which case the size is
    equal for all axes.
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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Notes
-----
The multi-dimensional filter is implemented as a sequence of
one-dimensional uniform filters. The intermediate arrays are stored
in the same data type as the output. Therefore, for output types
with a limited precision, the results may be imprecise because
intermediate results may be stored with insufficient precision.

Decorators:
  • @docfiller

minimum_filter1d(input, size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculate a one-dimensional minimum filter along the given axis.

The lines of the array along the given axis are filtered with a
minimum filter of given size.

Parameters
----------
input : array-like
    input array to filter
size : int
    length along which to calculate 1D minimum
axis : integer, optional
    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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

maximum_filter1d(input, size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculate a one-dimensional maximum filter along the given axis.

The lines of the array along the given axis are filtered with a
maximum filter of given size.

    Parameters
----------
input : array-like
    input array to filter
size : int
    length along which to calculate 1D maximum
axis : integer, optional
    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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

minimum_filter(input, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculates a multi-dimensional minimum filter.

Parameters
----------
input : array-like
    input array to filter
size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
    passed to the filter function.  Thus ``size=(n,m)`` is equivalent
    to ``footprint=np.ones((n,m))``.  We adjust ``size`` to the number
    of dimensions of the input array, so that, if the input array is
    shape (10,10,10), and ``size`` is 2, then the actual size used is
    (2,2,2).
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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

maximum_filter(input, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculates a multi-dimensional maximum filter.

Parameters
----------
input : array-like
    input array to filter
size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
    passed to the filter function.  Thus ``size=(n,m)`` is equivalent
    to ``footprint=np.ones((n,m))``.  We adjust ``size`` to the number
    of dimensions of the input array, so that, if the input array is
    shape (10,10,10), and ``size`` is 2, then the actual size used is
    (2,2,2).
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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

_rank_filter(input, rank, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0, operation='rank')

source code 
Decorators:
  • @docfiller

rank_filter(input, rank, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculates a multi-dimensional rank filter.

Parameters
----------
input : array-like
    input array to filter
rank : integer
    The rank parameter may be less then zero, i.e., rank = -1
    indicates the largest element.
size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
    passed to the filter function.  Thus ``size=(n,m)`` is equivalent
    to ``footprint=np.ones((n,m))``.  We adjust ``size`` to the number
    of dimensions of the input array, so that, if the input array is
    shape (10,10,10), and ``size`` is 2, then the actual size used is
    (2,2,2).
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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

median_filter(input, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)

source code 

Calculates a multi-dimensional median filter.

Parameters
----------
input : array-like
    input array to filter
size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
    passed to the filter function.  Thus ``size=(n,m)`` is equivalent
    to ``footprint=np.ones((n,m))``.  We adjust ``size`` to the number
    of dimensions of the input array, so that, if the input array is
    shape (10,10,10), and ``size`` is 2, then the actual size used is
    (2,2,2).
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
origin : scalar, optional
    The ``origin`` parameter controls the placement of the filter.
    Default 0

Decorators:
  • @docfiller

percentile_filter(input, percentile, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0)

source code 
Calculates a multi-dimensional percentile filter.

Parameters
----------
input : array-like
    input array to filter
percentile : scalar
    The percentile parameter may be less then zero, i.e.,
    percentile = -20 equals percentile = 80
size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
    passed to the filter function.  Thus ``size=(n,m)`` is equivalent
    to ``footprint=np.ones((n,m))``.  We adjust ``size`` to the number
    of dimensions of the input array, so that, if the input array is
    shape (10,10,10), and ``size`` is 2, then the actual size used is
    (2,2,2).
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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0

Decorators:
  • @docfiller

generic_filter1d(input, function, filter_size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0, extra_arguments=(), extra_keywords=None)

source code 
Calculate a one-dimensional filter along the given axis.

generic_filter1d iterates over the lines of the array, calling the
given function at each line. The arguments of the line are the
input line, and the output line. The input and output lines are 1D
double arrays.  The input line is extended appropriately according
to the filter size and origin. The output line must be modified
in-place with the result.

Parameters
----------
input : array-like
    input array to filter
function : callable
    function to apply along given axis
filter_size : scalar
    length of the filter
axis : integer, optional
    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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0
extra_arguments : sequence, optional
    Sequence of extra positional arguments to pass to passed function
extra_keywords : dict, optional
    dict of extra keyword arguments to pass to passed function

Decorators:
  • @docfiller

generic_filter(input, function, size=None, footprint=None, output=None, mode='reflect', cval=0.0, origin=0, extra_arguments=(), extra_keywords=None)

source code 
Calculates a multi-dimensional filter using the given function.

At each element the provided function is called. The input values
within the filter footprint at that element are passed to the function
as a 1D array of double values.

Parameters
----------
input : array-like
    input array to filter
function : callable
    function to apply at each element
size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
    passed to the filter function.  Thus ``size=(n,m)`` is equivalent
    to ``footprint=np.ones((n,m))``.  We adjust ``size`` to the number
    of dimensions of the input array, so that, if the input array is
    shape (10,10,10), and ``size`` is 2, then the actual size used is
    (2,2,2).
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
origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default 0
extra_arguments : sequence, optional
    Sequence of extra positional arguments to pass to passed function
extra_keywords : dict, optional
    dict of extra keyword arguments to pass to passed function

Decorators:
  • @docfiller

Variables Details [hide private]

_axis_doc

Value:
'''axis : integer, optional
    axis of ``input`` along which to calculate. Default is -1'''

_output_doc

Value:
'''output : array, optional
    The ``output`` parameter passes an array in which to store the
    filter output.'''

_size_foot_doc

Value:
'''size : scalar or tuple, optional
    See footprint, below
footprint : array, optional
    Either ``size`` or ``footprint`` must be defined.  ``size`` gives
    the shape that is taken from the input array, at every element
    position, to define the input to the filter function.
    ``footprint`` is a boolean array that specifies (implicitly) a
    shape, but also which of the elements within this shape will get
...

_mode_doc

Value:
'''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_doc

Value:
'''cval : scalar, optional
    Value to fill past edges of input if ``mode`` is \'constant\'. Def\
ault
    is 0.0'''

_origin_doc

Value:
'''origin : scalar, optional
The ``origin`` parameter controls the placement of the filter. Default\
 0'''

_extra_arguments_doc

Value:
'''extra_arguments : sequence, optional
    Sequence of extra positional arguments to pass to passed function'\
''

_extra_keywords_doc

Value:
'''extra_keywords : dict, optional
    dict of extra keyword arguments to pass to passed function'''

docdict

Value:
{'axis': '''axis : integer, optional
    axis of ``input`` along which to calculate. Default is -1''',
 'cval': '''cval : scalar, optional
    Value to fill past edges of input if ``mode`` is \'constant\'. Def\
ault
    is 0.0''',
 'extra_arguments': '''extra_arguments : sequence, optional
    Sequence of extra positional arguments to pass to passed function'\
...