inpystem.restore.LS_2D module

This module gathers regularized least square restoration methods adapted to 2D data.

The only method it implements for the moment is the L1-LS algorithm.

inpystem.restore.LS_2D.L1_LS(Y, Lambda, mask=None, init=None, Nit=None, verbose=True)

L1-LS algorithm.

The L1-LS algorithm denoises or reconstructs an image possibly spatially sub-sampled in the case of spatially sparse content in the DCT basis. It is well adapted to periodic data.

This algorithms solves the folowing regularization problem:

\[\gdef \x {\mathbf{x}} \gdef \y {\mathbf{y}} \hat{\x} = \mathrm{arg}\min_{ \x\in\mathbb{R}^{m \times n} } \frac{1}{2} ||(\x-\y)\cdot \Phi||_F^2 + \lambda ||\x\Psi||_1\]

where \(\mathbf{y}\) are the corrupted data, \(\Phi\) is a subsampling operator and \(\Psi\) is a 2D DCT operator.

Caution

It is strongly recomended to remove the mean before reconstruction. Otherwise, this value could be lost automaticaly by the algorithm in case of powerful high frequencies.

In the same way, normalizing the data is a good practice to have the parameter be low sensitive to data.

These two operations are implemented in this function.

Parameters
  • (m, n) numpy array (Y) – An image which mean has been removed.

  • Lambda (float) – Regularization parameter.

  • mask (optional, None, (m, n) numpy array) – A sampling mask which is True if the pixel is sampled. Default is None for full sampling.

  • init (optional, None, (m, n, l) numpy array) – The algorithm initialization. Default is None for random initialization.

  • Nit (optional, None, int) – Number of iteration in case of inpainting. If None, the iterations will stop as soon as the functional no longer evolve. Default is None.

  • verbose (optional, bool) – Indicates if information text is desired. Default is True.

Returns

  • (m, n) numpy array – The reconstructed/denoised image.

  • dict – A dictionary containing some extra info

Note

Infos in output dictionary:

  • E: In the case of partial reconstruction, the cost function evolution over iterations.

  • Gamma: The array of kept coefficients (order is Fortran-style).

  • nnz_ratio: the ratio Gamma.size/(m*n).