Itoh data-fidelity term for spatial unwrapping problems.
This class implements a data-fidelity term based on the \(\ell_2\) norm, but applied to the spatial finite differences of the variable and the wrapped differences of the data.
This is based on the Itoh condition for phase unwrapping [1].
It is designed to be used in conjunction with the deepinv.physics.SpatialUnwrapping class for spatial unwrapping tasks.
The data-fidelity term is defined as:
\[f(x,y) = \frac{1}{2\sigma^2} \| D x - w_{t}(Dy) \|^2\]
where \(D\) denotes the spatial finite differences operator, \(w_t\) denotes the wrapping operator, and \(\sigma\) denotes the noise level.
Parameters:
sigma (float) – Standard deviation of the noise to be used as a normalisation factor.
threshold (float) – Threshold value \(t\) used in the wrapping operator (default: 1.0).
Apply spatial finite differences to the input tensor.
Computes the horizontal and vertical finite differences of the input tensor x
using first-order differences along the last two spatial dimensions. The result
is a tensor containing both the horizontal and vertical gradients stacked along
a new dimension.
Parameters:
x (torch.Tensor) – Input tensor of shape (…, H, W), where H and W are spatial dimensions.
Returns:
(torch.Tensor) of shape (…, H, W, 2), where the last dimension contains
the horizontal and vertical finite differences, respectively.
Applies the adjoint (transpose) of the spatial finite difference operator to the input tensor.
This function computes the adjoint operation corresponding to spatial finite differences,
typically used in image processing and variational optimization problems. The input x
is expected to have its last dimension of size 2, representing the horizontal and vertical
finite differences \((D_h x, D_v x)\).
Parameters:
x (torch.Tensor) – Input tensor of shape (…, 2), where the last dimension contains
the horizontal and vertical finite differences.
Returns:
(torch.Tensor) The result of applying the adjoint finite difference operator, with the
same shape as the input except for the last dimension (which is removed).
Applies spatial finite differences to the input and wraps the result.
This method computes the spatial finite differences of the input tensor \(x\) using the \(D\) operator,
then applies modular rounding to the result. This is typically used in
applications where periodic boundary conditions or phase wrapping are required.
Parameters:
x (torch.Tensor) – Input tensor to which the spatial finite differences and wrapping are applied.
Returns:
(torch.Tensor) The wrapped finite differences of the input tensor.
where \(\left. \frac{\partial D}{\partial x} \right|_x\) is the Jacobian of \(D\) at \(x\), and \(\nabla_u \distance{u}{w_{t}(Dy)}\) is computed using grad_d with \(u = Dx\). The multiplication is computed using the D_adjoint method of the class.
Parameters:
x (torch.Tensor) – Variable \(x\) at which the gradient is computed.
Computes the gradient \(\nabla_u\distance{u}{w_{t}(Dy)}\), computed in \(u\).
Note that this is the gradient of
\(\distancename\) and not \(\datafidname\). This function directly calls deepinv.optim.Potential.grad() for the
specific distance function \(\distancename\).
Parameters:
u (torch.Tensor) – Variable \(u\) at which the gradient is computed.
y (torch.Tensor) – Data \(y\) of the same dimension as \(u\).
Returns:
(torch.Tensor) gradient of \(d\) in \(u\), i.e. \(\nabla_u\distance{u}{w_{t}(Dy)}\).
prox(x, y, physics=None, *args, gamma=1.0, **kwargs)[source]#
Proximal operator of \(\gamma \datafid{x}{y}\)
Compute the proximal operator of the fidelity term \(\operatorname{prox}_{\gamma \datafidname}\), i.e.
Computes the proximity operator \(\operatorname{prox}_{\gamma\distance{\cdot}{w_{t}(Dy)}}(u)\), computed at \(u\).
Note that this is the proximity operator of \(\distancename\) and not \(\datafidname\).
This function directly calls deepinv.optim.Potential.prox() for the
specific distance function \(\distancename\).
Parameters:
u (torch.Tensor) – Variable \(u\) at which the gradient is computed.
y (torch.Tensor) – Data \(y\) of the same dimension as \(u\).
Returns:
(torch.Tensor) gradient of \(d\) in \(u\), i.e. \(\nabla_u\distance{u}{w_{t}(Dy)}\).