{ } Raw JSON

bundles / scipy latest / scipy / signal / _signaltools / order_filter

function

scipy.signal._signaltools:order_filter

source: /scipy/signal/_signaltools.py :1521

Signature

def   order_filter ( a domain rank )

Summary

Perform an order filter on an N-D array.

Extended Summary

Perform an order filter on the array in. The domain argument acts as a mask centered over each pixel. The non-zero elements of domain are used to select elements surrounding each input pixel which are placed in a list. The list is sorted, and the output for that pixel is the element corresponding to rank in the sorted list.

Parameters

a : ndarray

The N-dimensional input array.

domain : array_like

A mask array with the same number of dimensions as a. Each dimension should have an odd number of elements.

rank : int

A non-negative integer which selects the element from the sorted list (0 corresponds to the smallest element, 1 is the next smallest element, etc.).

Returns

out : ndarray

The results of the order filter in an array with the same shape as a.

Notes

Array API Standard Support

order_filter has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ✅                   
PyTorch               ✅                     ⛔                   
JAX                   ⚠️ no JIT
Dask                  ⚠️ computes graph     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Examples

import numpy as np
from scipy import signal
x = np.arange(25).reshape(5, 5)
domain = np.identity(3)
x
signal.order_filter(x, domain, 0)
signal.order_filter(x, domain, 2)

Aliases

  • scipy.signal.order_filter

Referenced by