scarlet.fft

class scarlet.fft.Fourier(image, image_fft=None)[source]

Bases: object

An array that stores its Fourier Transform

The Fourier class is used for images that will make use of their Fourier Transform multiple times. In order to prevent numerical artifacts the same image convolved with different images might require different padding, so the FFT for each different shape is stored in a dictionary.

Attributes:
image

The real space image

shape

The shape of the real space image

Methods

fft(fft_shape, axes)

The FFT of an image for a given fft_shape along desired axes

from_fft(image_fft, fft_shape, image_shape)

Generate a new Fourier object from an FFT dictionary

fft(fft_shape, axes)[source]

The FFT of an image for a given fft_shape along desired axes

static from_fft(image_fft, fft_shape, image_shape, axes=None)[source]

Generate a new Fourier object from an FFT dictionary

If the fft of an image has been generated but not its real space image (for example when creating a convolution kernel), this method can be called to create a new Fourier instance from the k-space representation.

Parameters:
image_fft: array

The FFT of the image.

fft_shape: tuple

“Fast” shape of the image used to generate the FFT. This will be different than image_fft.shape if any of the dimensions are odd, since np.fft.rfft requires an even number of dimensions (for symmetry), so this tells np.fft.irfft how to go from complex k-space to real space.

image_shape: tuple

The shape of the image before padding. This will regenerate the image with the extra padding stripped.

axes: int or tuple

The dimension(s) of the array that will be transformed.

Returns:
result: Fourier

A Fourier object generated from the FFT.

property image

The real space image

property shape

The shape of the real space image

scarlet.fft.convolve(image, kernel, padding=3, axes=(-2, -1), return_Fourier=True)[source]

Convolve image with a kernel

Parameters:
image: array or `Fourier`

Image either as array or as Fourier object

kernel: array or `Fourier`

Convolution kernel either as array or as Fourier object

padding: int

Additional padding to use when generating the FFT to supress artifacts.

axes: tuple or None

Axes that contain the spatial information for the PSFs.

return_Fourier: bool

Whether to return Fourier or array

scarlet.fft.match_psf(psf1, psf2, padding=3, axes=(-2, -1), return_Fourier=True)[source]

Calculate the difference kernel to match psf1 to psf2

Parameters:
psf1: array or `Fourier`

PSF1 either as array or as Fourier object

psf2: array or `Fourier`

PSF1 either as array or as Fourier object

padding: int

Additional padding to use when generating the FFT to supress artifacts.

axes: tuple or None

Axes that contain the spatial information for the PSFs.

return_Fourier: bool

Whether to return Fourier or array

scarlet.fft.shift(image, shift, fft_shape=None, axes=(-2, -1), return_Fourier=True)[source]