Downsampling
- class deepinv.physics.Downsampling(img_size, filter=None, factor=2, device='cpu', padding='circular', **kwargs)[source]
Bases:
LinearPhysics
Downsampling operator for super-resolution problems.
It is defined as
\[y = S (h*x)\]where \(h\) is a low-pass filter and \(S\) is a subsampling operator.
- Parameters:
filter (torch.Tensor, str, NoneType) – Downsampling filter. It can be
'gaussian'
,'bilinear'
or'bicubic'
or a customtorch.Tensor
filter. IfNone
, no filtering is applied.factor (int) – downsampling factor
padding (str) – options are
'valid'
,'circular'
,'replicate'
and'reflect'
. Ifpadding='valid'
the blurred output is smaller than the image (no padding) otherwise the blurred output has the same size as the image.
- Examples:
Downsampling operator with a gaussian filter:
>>> from deepinv.physics import Downsampling >>> x = torch.zeros((1, 1, 32, 32)) # Define black image of size 32x32 >>> x[:, :, 16, 16] = 1 # Define one white pixel in the middle >>> physics = Downsampling(filter = "gaussian", img_size=(1, 32, 32), factor=2) >>> y = physics(x) >>> y[:, :, 7:10, 7:10] # Display the center of the downsampled image tensor([[[[0.0146, 0.0241, 0.0146], [0.0241, 0.0398, 0.0241], [0.0146, 0.0241, 0.0146]]]])
- A(x, filter=None, **kwargs)[source]
Applies the downsampling operator to the input image.
- Parameters:
x (torch.Tensor) – input image.
filter (None, torch.Tensor) – Filter \(h\) to be applied to the input image before downsampling. If not
None
, it uses this filter and stores it as the current filter.
- A_adjoint(y, filter=None, **kwargs)[source]
Adjoint operator of the downsampling operator.
- Parameters:
y (torch.Tensor) – downsampled image.
filter (None, torch.Tensor) – Filter \(h\) to be applied to the input image before downsampling. If not
None
, it uses this filter and stores it as the current filter.
- prox_l2(z, y, gamma, use_fft=True)[source]
If the padding is circular, it computes the proximal operator with the closed-formula of https://arxiv.org/abs/1510.00143.
Otherwise, it computes it using the conjugate gradient algorithm which can be slow if applied many times.
Examples using Downsampling
:
Stacking and concatenating forward operators.
A tour of forward sensing operators
Regularization by Denoising (RED) for Super-Resolution.
Vanilla Unfolded algorithm for super-resolution