{ } Raw JSON

bundles / scipy 1.17.1 / scipy / signal / _spline_filters / spline_filter

function

scipy.signal._spline_filters:spline_filter

source: /scipy/signal/_spline_filters.py :25

Signature

def   spline_filter ( Iin lmbda = 5.0 )

Summary

Smoothing spline (cubic) filtering of a rank-2 array.

Extended Summary

Filter an input data set, Iin, using a (cubic) smoothing spline of fall-off lmbda.

Parameters

Iin : array_like

input data set

lmbda : float, optional

spline smoothing fall-off value, default is 5.0.

Returns

res : ndarray

filtered input data

Notes

Array API Standard Support

spline_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

We can filter an multi dimensional signal (ex: 2D image) using cubic B-spline filter:
import numpy as np
from scipy.signal import spline_filter
import matplotlib.pyplot as plt
orig_img = np.eye(20)  # create an image
orig_img[10, :] = 1.0
sp_filter = spline_filter(orig_img, lmbda=0.1)
f, ax = plt.subplots(1, 2, sharex=True)
for ind, data in enumerate([[orig_img, "original image"],
                            [sp_filter, "spline filter"]]):
    ax[ind].imshow(data[0], cmap='gray_r')
    ax[ind].set_title(data[1])
plt.tight_layout()
plt.show()
fig-c97bf03765d0194f.png

Aliases

  • scipy.signal.spline_filter