ne, `input` is filtered along all axes. Otherwise,
    `input` is filtered along the specified axes. When `axes` is
    specified, any tuples used for `size` or `origin` must match the length
    of `axes`. The ith entry in any of these tuples corresponds to the ith
    entry in `axes`.

Returns
-------
generic_filter : ndarray
    Filtered array. Has the same shape as `input`.

Notes
-----
This function also accepts low-level callback functions with one of
the following signatures and wrapped in `scipy.LowLevelCallable`:

.. code:: c

   int callback(double *buffer, npy_intp filter_size,
                double *return_value, void *user_data)
   int callback(double *buffer, intptr_t filter_size,
                double *return_value, void *user_data)

The calling function iterates over the elements of the input and
output arrays, calling the callback function at each element. The
elements within the footprint of the filter at the current element are
passed through the ``buffer`` parameter, and the number of elements
within the footprint through ``filter_size``. The calculated value is
returned in ``return_value``. ``user_data`` is the data pointer provided
to `scipy.LowLevelCallable` as-is.

The callback function must return an integer error status that is zero
if something went wrong and one otherwise. If an error occurs, you should
normally set the python error status with an informative message
before returning, otherwise a default error message is set by the
calling function.

In addition, some other low-level function pointer specifications
are accepted, but these are for backward compatibility only and should
not be used in new code.

Examples
--------
Import the necessary modules and load the example image used for
filtering.

>>> import numpy as np
>>> from scipy import datasets
>>> from scipy.ndimage import zoom, generic_filter
>>> import matplotlib.pyplot as plt
>>> ascent = zoom(datasets.ascent(), 0.5)

Compute a maximum filter with kernel size 5 by passing a simple NumPy
aggregation function as argument to `function`.

>>> maximum_filter_result = generic_filter(ascent, np.amax, [5, 5])

While a maximum filter could also directly be obtained using
`maximum_filter`, `generic_filter` allows generic Python function or
`scipy.LowLevelCallable` to be used as a filter. Here, we compute the
range between maximum and minimum value as an example for a kernel size
of 5.

>>> def custom_filter(image):
...     return np.amax(image) - np.amin(image)
>>> custom_filter_result = generic_filter(ascent, custom_filter, [5, 5])

Plot the original and filtered images.

>>> fig, axes = plt.subplots(3, 1, figsize=(3, 9))
>>> plt.gray()  # show the filtered result in grayscale
>>> top, middle, bottom = axes
>>> for ax in axes:
...     ax.set_axis_off()  # remove coordinate system
>>> top.imshow(ascent)
>>> top.set_title("Original image")
>>> middle.imshow(maximum_filter_result)
>>> middle.set_title("Maximum filter, Kernel: 5x5")
>>> bottom.imshow(custom_filter_result)
>>> bottom.set_title("Custom filter, Kernel: 5x5")
>>> fig.tight_layout()

r×