Functional#
The toolbox is based on efficient PyTorch implementations of basic operations such as diagonal multipliers,
Fourier transforms, convolutions, product-convolutions, Radon transform, interpolation mappings.
Similar to the PyTorch structure, they are available within deepinv.physics.functional
.
>>> import torch
>>> import deepinv as dinv
>>> x = torch.zeros((1, 1, 16, 16)) # Define black image of size 16x16
>>> x[:, :, 8, 8] = 1 # Define one white pixel in the middle
>>> filter = torch.ones((1, 1, 3, 3)) / 4
>>>
>>> padding = "circular"
>>> Ax = dinv.physics.functional.conv2d(x, filter, padding)
>>> print(Ax[:, :, 7:10, 7:10])
tensor([[[[0.2500, 0.2500, 0.2500],
[0.2500, 0.2500, 0.2500],
[0.2500, 0.2500, 0.2500]]]])
>>>
>>> _ = torch.manual_seed(0)
>>> y = torch.randn_like(Ax)
>>> z = dinv.physics.functional.conv_transpose2d(y, filter, padding)
>>> print((Ax * y).sum(dim=(1, 2, 3)) - (x * z).sum(dim=(1, 2, 3)))
tensor([5.9605e-08])
Function |
Description |
---|---|
Performs 2D convolution on input data, commonly used in image processing for filtering and feature extraction. |
|
Computes the 2D transposed convolution (deconvolution), used for upsampling or reversing convolutional operations. |
|
Performs 2D convolution using the Fast Fourier Transform (FFT), offering faster performance for large kernel sizes. |
|
Computes the 2D transposed convolution with FFT, efficiently implementing upsampling or deconvolution. |
|
Performs 3D convolution using FFT, suitable for volumetric data processing in applications like medical imaging. |
|
Computes 3D transposed convolution using FFT, often used for volumetric data reconstruction or upsampling. |
|
Implements a 2D product convolution, enabling spatially varying convolution across the input image. |
|
Applies an element-wise multiplier to the input data, typically used to modify pixel intensities or apply masks. |
|
Applies the adjoint of an element-wise multiplier, effectively reversing the scaling applied by multiplier. |
|
Computes the Radon transform, used in tomography to simulate the projection data from an object. |
|
Computes the inverse Radon transform, reconstructing an image from projection data as in CT scan reconstruction. |
|
Computes the histogram of a multi-dimensional dataset, useful in statistical analysis and data visualization. |
|
Computes the histogram of 1D or 2D data, often used for intensity distribution analysis in image processing. |