BlindRL#
- class deepinv.optim.BlindRL(x_prior=None, k_prior=None, lambda_reg_x=0.0, lambda_reg_k=0.0, g_param=None, g_param_kernel=None, x_steps=1, k_steps=1, kernel_size=(17, 17), normalize_kernel=True, use_fft=False, eps=1e-15, max_iter=100, crit_conv='residual', thres_conv=1e-5, early_stop=False, custom_metrics=None, init=None, cost_fn=None, params_algo=None, unfold=False, DEQ=None, anderson_acceleration=False, **kwargs)[source]#
Bases:
BaseOptimBlind Richardson-Lucy deconvolution for Poisson inverse problems.
This algorithm alternates multiplicative MLEM updates for the image \(x\) and the blur kernel \(h\) under the model
\[y \sim \operatorname{Poisson}(h * x).\]The updates are given by:
\[h^{(k+1)} = \Pi_{\Delta}\left[\frac{h^{(k)}}{(x^{(k)})^\dagger * \mathbf{1}} \odot (x^{(k)})^\dagger * \left(\frac{y}{x^{(k)} * h^{(k)}}\right)\right],\]and:
\[x^{(k+1)} = \frac{x^{(k)}}{(h^{(k+1)})^\dagger * \mathbf{1}} \odot (h^{(k+1)})^\dagger * \left(\frac{y}{h^{(k+1)} * x^{(k)}}\right).\]where \(z^\dagger\) denotes the spatially flipped \(z\), such that \(z^\dagger *\) is the adjoint of convolution by \(z\). The kernel is constrained to be nonnegative and, by default, normalized to unit sum by the Pi_{Delta} operation after each kernel update.
Image and kernel priors can be used. The regularized algorithm is implemented using the the One-Step-Late (OSL) heuristic of Green [1]. The kernel and image updates then become:
\[h^{(k+1)} = \Pi_{\Delta}\left[\frac{h^{(k)}}{(x^{(k)})^\dagger * \mathbf{1} + \lambda_h \nabla R_h(h^{(k)})} \odot (x^{(k)})^\dagger * \left(\frac{y}{x^{(k)} * h^{(k)}}\right)\right].\]\[x^{(k+1)} = \frac{x^{(k)}}{(h^{(k+1)})^\dagger * \mathbf{1} + \lambda_x \nabla R_x(x^{(k)})} \odot (h^{(k+1)})^\dagger * \left(\frac{y}{h^{(k+1)} * x^{(k)}}\right),\]Note
The parameter
use_fftenables to swap standard convolutions used to update the image and the kernel for FFT based convolutions, which significantly speeds up the algorithm when using a large image and estimating a large kernel. The speedup is particularly important for kernels bigger than 30x30. For small kernels (<15x15) and images (<128x128), it is more efficient to use standard convolutions.- Parameters:
x_prior (deepinv.optim.Prior) β optional image prior. Default:
None.k_prior (deepinv.optim.Prior) β optional kernel prior. Default:
None.lambda_reg_x (float) β image regularization parameter. Default:
0.0.lambda_reg_k (float) β kernel regularization parameter. Default:
0.0.g_param (float) β parameter for the image prior. Default:
None.g_param_kernel (float) β parameter for the kernel prior. Default:
None.x_steps (int) β number of inner image updates per iteration. Default:
1.k_steps (int) β number of inner kernel updates per iteration. Default:
1.kernel_size (int, tuple[int, int]) β spatial size of the default uniform kernel. An explicit kernel in
initoverrides this size. Default:(17, 17).normalize_kernel (bool) β whether to normalize the kernel to unit sum. Default:
True.use_fft (bool) β whether to use FFT implementations for image and kernel convolutions. Default:
False.eps (float) β numerical stability constant. Default:
1e-15.max_iter (int) β number of alternating BlindRL iterations. Default:
100.init (tuple[torch.Tensor, torch.Tensor]) β initial image and blur kernel
(x0, k0). IfNone,x0is initialized withyandk0with a uniform kernel of the same size askernel_size.cost_fn (Callable) β optional cost function. If omitted, the Poisson negative log-likelihood plus explicit image and kernel priors is used.
params_algo (dict) β optionally provide BlindRL parameters directly.
- References:
- forward(y, x_gt=None, compute_metrics=False, **kwargs)[source]#
Run Blind Richardson-Lucy deconvolution.
- Parameters:
y (torch.Tensor) β blurred image of shape
(B, C, H, W).x_gt (torch.Tensor) β optional ground-truth image used to compute metrics. Default:
None.compute_metrics (bool) β whether to compute reconstruction metrics. Default:
False.
- Returns:
estimated image and blur kernel
(x, k). Ifcompute_metricsisTrue, return((x, k), metrics).