{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / _fft_based / butterworth

function

skimage.filters._fft_based:butterworth

source: /dev/scikit-image/src/skimage/filters/_fft_based.py :57

Signature

def   butterworth ( image cutoff_frequency_ratio = 0.005 high_pass = True order = 2.0 channel_axis = None * squared_butterworth = True npad = 0 )

Summary

Apply a Butterworth filter to enhance high or low frequency features.

Extended Summary

This filter is defined in the Fourier domain.

Parameters

image : (M[, N[, ..., P]][, C]) ndarray

Input image.

cutoff_frequency_ratio : float, optional

Determines the position of the cut-off relative to the shape of the FFT. Receives a value between [0, 0.5].

high_pass : bool, optional

Whether to perform a high pass filter. If False, a low pass filter is performed.

order : float, optional

Order of the filter which affects the slope near the cut-off. Higher order means steeper slope in frequency space.

channel_axis : int, optional

If there is a channel dimension, provide the index here. If None (default) then all axes are assumed to be spatial dimensions.

squared_butterworth : bool, optional

When True, the square of a Butterworth filter is used. See notes below for more details.

npad : int, optional

Pad each edge of the image by npad pixels using numpy.pad's mode='edge' extension.

Returns

result : ndarray

The Butterworth-filtered image.

Notes

A band-pass filter can be achieved by combining a high-pass and low-pass filter. The user can increase npad if boundary artifacts are apparent.

The "Butterworth filter" used in image processing textbooks (e.g. [1], [2]) is often the square of the traditional Butterworth filters as described by [3], [4]. The squared version will be used here if squared_butterworth is set to True. The lowpass, squared Butterworth filter is given by the following expression for the lowpass case:

with the highpass case given by

where is the absolute value of the spatial frequency, is the sampling frequency, the cutoff_frequency_ratio, and is the filter order [1]. When squared_butterworth=False, the square root of the above expressions are used instead.

Note that cutoff_frequency_ratio is defined in terms of the sampling frequency, . The FFT spectrum covers the Nyquist range () so cutoff_frequency_ratio should have a value between 0 and 0.5. The frequency response (gain) at the cutoff is 0.5 when squared_butterworth is true and when it is false.

Examples

Apply a high-pass and low-pass Butterworth filter to a grayscale and color image respectively:
from skimage.data import camera, astronaut
from skimage.filters import butterworth
high_pass = butterworth(camera(), 0.07, True, 8)
low_pass = butterworth(astronaut(), 0.01, False, 4, channel_axis=-1)

Aliases

  • skimage.filters.butterworth