deepmr.prox.tv_denoise#
- deepmr.prox.tv_denoise(input, ndim, ths=0.1, device=None, verbose=False, niter=100, crit=1e-05, x2=None, u2=None)[source]#
Apply isotropic Total Variation denoising.
This algorithm converges to the unique image \(x\) that is the solution of
\[\underset{x}{\arg\min} \; \frac{1}{2}\|x-y\|_2^2 + \gamma \|Dx\|_{1,2},\]where \(D\) maps an image to its gradient field.
The problem is solved with an over-relaxed Chambolle-Pock algorithm (see L. Condat, “A primal-dual splitting method for convex optimization involving Lipschitzian, proximable and linear composite terms”, J. Optimization Theory and Applications, vol. 158, no. 2, pp. 460-479, 2013.
Code (and description) adapted from
deepinv
, in turn adapted from Laurent Condat’s matlab version (https://lcondat.github.io/software.html) and Daniil Smolyakov’s code.This algorithm is implemented with warm restart, i.e. the primary and dual variables are kept in memory between calls to the forward method. This speeds up the computation when using this class in an iterative algorithm.
- Parameters:
input (np.ndarray | torch.Tensor) – Input image of shape (…, n_ndim, …, n_0).
ndim (int) – Number of spatial dimensions, can be either
2
or3
.ths (float, optional) – Denoise threshold. The default is``0.1``.
device (str, optional) – Device on which the wavelet transform is computed. The default is
None
(infer from input).verbose (bool, optional) – Whether to print computation details or not. The default is
False
.niter (int, optional,) – Maximum number of iterations. The default is
1000
.crit (float, optional) – Convergence criterion. The default is 1e-5.
x2 (torch.Tensor, optional) – Primary variable for warm restart. The default is
None
.u2 (torch.Tensor, optional) – Dual variable for warm restart. The default is
None
.
Notes
The regularization term \(\|Dx\|_{1,2}\) is implicitly normalized by its Lipschitz constant, i.e. \(\sqrt{8}\), see e.g. A. Beck and M. Teboulle, “Fast gradient-based algorithms for constrained total variation image denoising and deblurring problems”, IEEE T. on Image Processing. 18(11), 2419-2434, 2009.
- Returns:
output – Denoised image of shape (…, n_ndim, …, n_0).
- Return type:
np.ndarray | torch.Tensor