pad_image_to_fft#
- deeptrack.image.pad_image_to_fft(image: Image | ndarray, axes: Iterable[int] = (0, 1)) Image | ndarray #
Pads an image to optimize Fast Fourier Transform (FFT) performance.
This function pads an image by adding zeros to the end of specified axes so that their lengths match the nearest larger size in _FASTEST_SIZES. These sizes are selected to optimize FFT computations.
Parameters#
- imageImage or np.ndarray
The input image to pad. It should be an instance of the Image class or any array-like structure compatible with FFT operations.
- axesIterable[int], optional
The axes along which to apply padding. Defaults to (0, 1).
Returns#
- Image or np.ndarray
The padded image with dimensions optimized for FFT performance.
Raises#
- ValueError
If no suitable size is found in _FASTEST_SIZES for any axis length.
Example#
>>> import numpy as np >>> from deeptrack.image import Image, pad_image_to_fft
Pad an Image object:
>>> img = Image(np.zeros((7, 13))) >>> padded_img = pad_image_to_fft(img) >>> print(padded_img.shape) (8, 16)
Pad a NumPy array:
>>> img = np.zeros((5, 11))) >>> padded_img = pad_image_to_fft(img) >>> print(padded_img.shape) (6, 12)