inpystem.restore.LS_CLS module¶
This module implements regularized least square restoration methods adapted to 3D data.
The two methods it gathers are
Cosine Least Square (CLS) algorith,
Post-LS Cosine Least Square (Post_LS_CLS) algorithm.
-
inpystem.restore.LS_CLS.
CLS
(Y, Lambda, mask=None, PCA_transform=True, PCA_th='auto', init=None, Nit=None, verbose=True)¶ Cosine Least Square algorithm
The CLS algorithm denoises or reconstructs a multi-band image possibly spatially sub-sampled in the case of spatially sparse content in the DCT basis. It is well adapted to periodic data.
This algorithm solves the folowing optimization problem:
\[\gdef \X {\mathbf{X}} \gdef \Y {\mathbf{Y}} \gdef \H {\mathbf{H}} \gdef \I {\mathcal{I}} \hat{\X} = \underset{\X\in\mathbb{R}^{m \times n \times B}}{\arg\min} \frac{1}{2}||\Y_\I - \X_\I||_\mathrm{F}^2 + \lambda ||\X \Psi||_{2, 1}\]where \(\mathbf{Y}\) are the corrupted data, \(\mathbf{D}\) is a spatial finite difference operator and \(\mathcal{I}\) is the set of all sampled pixels.
This algorithm can perform a PCA pre-processing operation to estimate:
the data subspace basis \(\mathbf{H}\),
the subspace dimension \(R\).
This is particularly usefull to reduce the data dimension and the execution time and to impose a data low-rank property.
Caution
It is strongly recomended to perform PCA before running the algorithm core. This operation is integrated in this function.
In case this pre-processing step has already been done, set the PCA_transform parameter to False to disable the PCA step included in the SSS function. If PCA_transform is set to False, the PCA_info parameter is required.
- Parameters
(m, n, l) numpy array (Y) – A 3D multi-band image.
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.
PCA_transform (optional, bool) – Enables the PCA transformation if True, otherwise, no PCA transformation is processed. Default is True.
PCA_th (optional, int, str) – The desired data dimension after dimension reduction. Possible values are ‘auto’ for automatic choice, ‘max’ for maximum value and an int value for user value. Default is ‘auto’.
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, l) numpy array – The reconstructed/denoised multi-band 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)H
: the basis of the chosen signal subspace
-
inpystem.restore.LS_CLS.
Post_LS_CLS
(Y, Lambda, mask=None, PCA_transform=True, PCA_th='auto', init=None, Nit=None, verbose=True)¶ Post-Lasso CLS algorithm.
This algorithms consists in applying CLS to restore the data and determine the data support in DCT basis. A post-least square optimization is performed to reduce the coefficients bias.
- Parameters
(m, n, l) numpy array (Y) – A 3D multi-band image.
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.
PCA_transform (optional, bool) – Enables the PCA transformation if True, otherwise, no PCA transformation is processed. Default is True.
PCA_th (optional, int, str) – The desired data dimension after dimension reduction. Possible values are ‘auto’ for automatic choice, ‘max’ for maximum value and an int value for user value. Default is ‘auto’.
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, l) numpy array – The reconstructed/denoised multi-band image.
tuple – A 2-tuple whose alements are the CLS and reffitting information dictionaries.
Note
Infos in output dictionary:
E_CLS
: In the case of partial reconstruction, the cost function evolution over iterations.E_post_ls
: 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)H
: the basis of the chosen signal subspace