torchbp.ops.resample module
- torchbp.ops.resample.resample_1d_knab(x, num, axis=-1, order=6, oversample=1.5)[source]
Resample a signal to num samples using Knab interpolation.
Like
resample_1d_lanczos()but uses a Knab kernel with a Kaiser-Bessel window matched to the signal oversampling ratio, giving better accuracy than Lanczos when the oversampling is known. Seeresample_1d_lanczos()for the num, axis, and decimation semantics.- Parameters:
x (Tensor) – Input signal. Any shape. Supports complex64 and float32.
num (int) – Number of output samples along axis. Must be >= 1.
axis (int) – Axis to resample along. Default -1.
order (int) – Kernel order (2–8). Default 6.
oversample (float) – Signal oversampling ratio. Default 1.5.
- Returns:
Resampled signal, same dtype as x, with length num along axis.
- Return type:
Tensor
- torchbp.ops.resample.resample_1d_lanczos(x, num, axis=-1, order=6)[source]
Resample a signal to num samples using Lanczos interpolation.
Changes the number of samples along axis to num, similar to
scipy.signal.resample(x, num)but implemented as a zero-phase windowed-sinc interpolation in the sample domain.num == Nis the identity,num > Nupsamples (fractional interpolation), andnum < Ndecimates. When decimating, the kernel is lowpassed to the output Nyquist frequency to suppress aliasing.Output element
kreads the input at continuous positionk * N / num, whereNis the input length along axis. Any number of leading/trailing dimensions is supported; they are processed independently.- Parameters:
x (Tensor) – Input signal. Any shape. Supports complex64 and float32.
num (int) – Number of output samples along axis. Must be >= 1.
axis (int) – Axis to resample along. Default -1.
order (int) – Lanczos kernel order (2–8). Default 6.
- Returns:
Resampled signal, same dtype as x, with length num along axis.
- Return type:
Tensor
- torchbp.ops.resample.resample_2d_knab(img, shift_r, shift_az, order=6, oversample=1.5)[source]
Resample a 2D image using Knab interpolation with a per-pixel shift field.
The Knab kernel uses a Kaiser-Bessel window matched to the signal oversampling ratio, giving better accuracy than Lanczos when the oversampling is known.
Each output pixel
(i, j)reads from the input at(i + shift_r[i, j], j + shift_az[i, j]).- Parameters:
img (Tensor) – Input image. Shape
[Nr, Naz]or[nbatch, Nr, Naz]. Supports complex64 and float32.shift_r (Tensor float32
[Nr, Naz]) – Per-pixel shift in the first (range) dimension.shift_az (Tensor float32
[Nr, Naz]) – Per-pixel shift in the second (azimuth) dimension.order (int) – Kernel order (2–8). Default 6.
oversample (float) – Signal oversampling ratio. Default 1.5.
- Returns:
Resampled image, same shape and dtype as img.
- Return type:
Tensor
- torchbp.ops.resample.resample_2d_lanczos(img, shift_r, shift_az, order=6)[source]
Resample a 2D image using Lanczos interpolation with a per-pixel shift field.
Each output pixel
(i, j)reads from the input at(i + shift_r[i, j], j + shift_az[i, j])using a Lanczos kernel of the given order.- Parameters:
img (Tensor) – Input image. Shape
[Nr, Naz]or[nbatch, Nr, Naz]. Supports complex64 and float32.shift_r (Tensor float32
[Nr, Naz]) – Per-pixel shift in the first (range) dimension.shift_az (Tensor float32
[Nr, Naz]) – Per-pixel shift in the second (azimuth) dimension.order (int) – Lanczos kernel order (2–8). Default 6.
- Returns:
Resampled image, same shape and dtype as img.
- Return type:
Tensor