Core Functions#

Fourier Operations#

class fouriercrop.FourierCrop(pad_mode: int = 0, dim: Tuple = (-3, -2, -1), epsilon: float = 1e-06)[source]#

Enables downsampling and other operations based on Fourier domain cropping.

It supports 2D tensors in the BCHW format and 3D tensors in the BCDHW format.

static crop_center(x: Tensor, bin_factor: int = 2) Tensor[source]#

Crops the central region of a tensor based on a specified bin_factor factor.

Parameters:
  • x (torch.Tensor) – Input 2D tensors in the BCHW format or 3D tensors in the BCDHW format.

  • bin_factor (int, optional) – Factor determining the size of the cropped region (default=2).

Returns:

Cropped tensor.

Return type:

torch.Tensor

static crop_center_pad(x: Tensor, bin_factor: int = 2) Tensor[source]#

Crops the central region of a tensor and pads it back to its original size.

Parameters:
  • x (torch.Tensor) – Input 2D tensors in the BCHW format or 3D tensors in the BCDHW format.

  • bin_factor (int, optional) – Factor determining the size of the cropped region (default=2).

Returns:

Cropped and padded tensor.

Return type:

torch.Tensor

static fft(x: Tensor, dim: Tuple = (-3, -2, -1), norm: str = 'ortho') Tensor[source]#

Applies 3D Fast Fourier Transform (FFT) to input data.

static ifft(x: Tensor, dim: Tuple = (-3, -2, -1), norm: str = 'ortho') Tensor[source]#

Applies Inverse Fast Fourier Transform (IFFT) to input data.

static norm(x: Tensor, dim: Tuple = (-3, -2, -1), epsilon: float = 1e-06) Tensor[source]#

Normalizes a tensor by its mean and standard deviation.

static pad_center(x: Tensor, bin_factor: int = 2) Tensor[source]#

Centers the original tensor within the new padded tensor.