View Source NxSignal.Filters (NxSignal v0.3.0)
Common filter functions.
Link to this section Summary
Functions: Filters
FIR filter design using the window method.
Performs a median filter on a tensor.
Applies a Wiener filter to the given Nx tensor.
Link to this section Functions: Filters
FIR filter design using the window method.
Computes the coefficients of a finite impulse response (FIR) filter.
The filter has linear phase (Type I for odd num_taps, Type II for even).
Type II filters have a zero at Nyquist, so a filter requiring gain there
must use an odd number of taps.
arguments
Arguments
num_taps- number of filter coefficients (filter order + 1).cutoff- list of cutoff frequencies in the same units assampling_rate.
options
Options
:window- window function to apply. One of:hamming,:hann,:blackman,:bartlett,:rectangular, or{:kaiser, beta}. Defaults to:hamming.:pass_zero- iftrue, the DC gain is 1 (lowpass or bandstop); iffalse, the DC gain is 0 (highpass or bandpass). Defaults totrue.:scale- iftrue, normalise the coefficients so the frequency response is exactly 1 at a reference frequency. Defaults totrue.:sampling_rate- the sampling rate in Hz;cutoffis given in the same units. Defaults to2.0so cutoffs are already normalised to[0, 1]where1equals Nyquist.:type- output tensor type. Defaults to{:f, 32}.
examples
Examples
iex> coeffs = NxSignal.Filters.firwin(5, [0.3], window: :hamming, sampling_rate: 2.0)
iex> Nx.shape(coeffs)
{5}
Performs a median filter on a tensor.
options
Options
:kernel_shape- the shape of the sliding window. It must be compatible with the shape of the tensor.
Applies a Wiener filter to the given Nx tensor.
options
Options
* `:kernel_size` - filter size given either a number or a tuple.
If a number is given, a kernel with the given size, and same number of axes
as the input tensor will be used. Defaults to `3`.
* `:noise` - noise power, given as a scalar. This will be estimated based on the input tensor if `nil`. Defaults to `nil`.
examples
Examples
iex> t = Nx.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]])
iex> NxSignal.Filters.wiener(t, kernel_size: {2, 2}, noise: 10)
#Nx.Tensor<
f32[3][3]
[
[0.25, 0.75, 1.25],
[1.25, 3.0, 4.0],
[2.75, 6.0, 7.0]
]
>