corrct.regularizers
Regularizers module.
@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France
Module Contents
Classes
Initialize a base regularizer class, that defines the Regularizer object interface. |
|
Gradient regularizer. |
|
Total Variation (TV) regularizer in 1D. It can be used to promote piece-wise constant reconstructions. |
|
Total Variation (TV) regularizer in 2D. It can be used to promote piece-wise constant reconstructions. |
|
Total Variation (TV) regularizer in 3D. It can be used to promote piece-wise constant reconstructions. |
|
Total Variation (TV) regularizer in 2D. It can be used to promote piece-wise constant reconstructions. |
|
Total Variation (TV) regularizer in 3D. It can be used to promote piece-wise constant reconstructions. |
|
It can be used to promote smooth reconstructions. |
|
It can be used to promote smooth reconstructions. |
|
It can be used to promote smooth reconstructions. |
|
Laplacian regularizer. It can be used to promote smooth reconstructions. |
|
Laplacian regularizer in 1D. It can be used to promote smooth reconstructions. |
|
Laplacian regularizer in 2D. It can be used to promote smooth reconstructions. |
|
Laplacian regularizer in 3D. It can be used to promote smooth reconstructions. |
|
l1-norm regularizer. It can be used to promote sparse reconstructions. |
|
Base stationary wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain. |
|
l1-norm Wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain. |
|
l1-norm Wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain. |
|
l1-norm Wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain. |
|
Base decimated wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain. |
|
l1-norm decimated wavelet regularizer. It can be used to promote sparse reconstructions. |
|
l1-norm decimated wavelet regularizer. It can be used to promote sparse reconstructions. |
|
l1-norm decimated wavelet regularizer. It can be used to promote sparse reconstructions. |
|
Median filter regularizer base class. It can be used to promote filtered reconstructions. |
|
l1-norm median filter regularizer. It can be used to promote filtered reconstructions. |
|
l2-norm median filter regularizer. It can be used to promote filtered reconstructions. |
|
Fourier regularizer. It can be used to promote sparse reconstructions in the Fourier domain. |
|
Total Nuclear Variation (TNV) regularizer. |
|
Vectorial Total Variation (VTV) regularizer. |
|
Nuclear-norm Wavelet regularizer. |
|
l1-norm vectorial Wavelet regularizer. It can be used to promote compressed reconstructions. |
|
Regularizer based on the Singular Value Decomposition. |
|
Lower limit constraint. It can be used to promote reconstructions in certain regions of solution space. |
|
Upper limit constraint. It can be used to promote reconstructions in certain regions of solution space. |
Data
API
- corrct.regularizers.NDArrayInt
None
- class corrct.regularizers.BaseRegularizer(weight: Union[float, numpy.typing.NDArray], norm: corrct.data_terms.DataFidelityBase, upd_mask: Optional[numpy.typing.NDArray] = None, dtype: numpy.typing.DTypeLike = np.float32)[source]
Bases:
abc.ABC
Initialize a base regularizer class, that defines the Regularizer object interface.
Parameters
weight : Union[float, NDArray] The weight of the regularizer. norm : DataFidelityBase The norm of the regularizer minimization.
Initialization
- __reg_name__ = <Multiline-String>
- weight: numpy.typing.NDArray
None
- dtype: numpy.typing.DTypeLike
None
- op: Union[corrct.operators.BaseTransform, None]
None
- sigma: Union[float, numpy.typing.NDArray]
None
- upd_mask: Optional[numpy.typing.NDArray]
None
- upper() str [source]
Return the upper case name of the regularizer.
Returns
str Upper case string name of the regularizer.
- lower() str [source]
Return the lower case name of the regularizer.
Returns
str Lower case string name of the regularizer.
- abstract initialize_sigma_tau(primal: numpy.typing.NDArray) Union[float, numpy.typing.NDArray] [source]
Initialize the internal state, operator, and sigma. It then returns the tau.
Parameters
primal : NDArray The primal vector.
Returns
Union[float, NDArray] The tau to be used in the SIRT or PDHG algorithm.
- initialize_dual() numpy.typing.NDArray [source]
Return the initialized dual.
Returns
NDArray Initialized (zero) dual.
- update_dual(dual: numpy.typing.NDArray, primal: numpy.typing.NDArray) None [source]
Update the dual in-place.
Parameters
dual : NDArray Current stat of the dual. primal : NDArray Primal or over-relaxation of the primal.
- apply_proximal(dual: numpy.typing.NDArray) None [source]
Apply the proximal operator to the dual in-place.
Parameters
dual : NDArray The dual to be applied the proximal on.
- class corrct.regularizers.Regularizer_Grad(weight: Union[float, numpy.typing.NDArray], ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l12())[source]
Bases:
corrct.regularizers.BaseRegularizer
Gradient regularizer.
When used with l1-norms, it promotes piece-wise constant reconstructions. When used with l2-norm, it promotes smooth reconstructions.
Parameters
weight : Union[float, NDArray] The weight of the regularizer. ndims : int, optional The number of dimensions. The default is 2. axes : Sequence, optional The axes over which it computes the gradient. If None, it uses the last 2. The default is None. pad_mode: str, optional The padding mode to use for the linear convolution. The default is “edge”. norm : DataFidelityBase, optional The norm of the regularizer minimization. The default is DataFidelity_l12().
Initialization
- __reg_name__
‘grad’
- class corrct.regularizers.Regularizer_TV1D(weight: Union[float, numpy.typing.NDArray], axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l12())[source]
Bases:
corrct.regularizers.Regularizer_Grad
Total Variation (TV) regularizer in 1D. It can be used to promote piece-wise constant reconstructions.
Initialization
- __reg_name__
‘TV1D’
- class corrct.regularizers.Regularizer_TV2D(weight: Union[float, numpy.typing.NDArray], axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l12())[source]
Bases:
corrct.regularizers.Regularizer_Grad
Total Variation (TV) regularizer in 2D. It can be used to promote piece-wise constant reconstructions.
Initialization
- __reg_name__
‘TV2D’
- class corrct.regularizers.Regularizer_TV3D(weight: Union[float, numpy.typing.NDArray], axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l12())[source]
Bases:
corrct.regularizers.Regularizer_Grad
Total Variation (TV) regularizer in 3D. It can be used to promote piece-wise constant reconstructions.
Initialization
- __reg_name__
‘TV3D’
- class corrct.regularizers.Regularizer_HubTV2D(weight: Union[float, numpy.typing.NDArray], huber_size: float, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_Grad
Total Variation (TV) regularizer in 2D. It can be used to promote piece-wise constant reconstructions.
Initialization
- __reg_name__
‘HubTV2D’
- class corrct.regularizers.Regularizer_HubTV3D(weight: Union[float, numpy.typing.NDArray], huber_size: float, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_Grad
Total Variation (TV) regularizer in 3D. It can be used to promote piece-wise constant reconstructions.
Initialization
- __reg_name__
‘HubTV3D’
- class corrct.regularizers.Regularizer_smooth1D(weight: Union[float, numpy.typing.NDArray], axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l2())[source]
Bases:
corrct.regularizers.Regularizer_Grad
It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘smooth1D’
- class corrct.regularizers.Regularizer_smooth2D(weight: Union[float, numpy.typing.NDArray], axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l2())[source]
Bases:
corrct.regularizers.Regularizer_Grad
It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘smooth2D’
- class corrct.regularizers.Regularizer_smooth3D(weight: Union[float, numpy.typing.NDArray], axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l2())[source]
Bases:
corrct.regularizers.Regularizer_Grad
It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘smooth3D’
- class corrct.regularizers.Regularizer_lap(weight: Union[float, numpy.typing.NDArray], ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.BaseRegularizer
Laplacian regularizer. It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘lap’
- class corrct.regularizers.Regularizer_lap1D(weight, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_lap
Laplacian regularizer in 1D. It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘lap1D’
- class corrct.regularizers.Regularizer_lap2D(weight, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_lap
Laplacian regularizer in 2D. It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘lap2D’
- class corrct.regularizers.Regularizer_lap3D(weight, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_lap
Laplacian regularizer in 3D. It can be used to promote smooth reconstructions.
Initialization
- __reg_name__
‘lap3D’
- class corrct.regularizers.Regularizer_l1(weight: Union[float, numpy.typing.NDArray], upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1())[source]
Bases:
corrct.regularizers.BaseRegularizer
l1-norm regularizer. It can be used to promote sparse reconstructions.
Initialization
- __reg_name__
‘l1’
- class corrct.regularizers.Regularizer_swl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, normalized: bool = False, min_approx: bool = True, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1())[source]
Bases:
corrct.regularizers.BaseRegularizer
Base stationary wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain.
Initialization
- __reg_name__
‘swl’
- class corrct.regularizers.Regularizer_l1swl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, normalized: bool = False, min_approx: bool = True)[source]
Bases:
corrct.regularizers.Regularizer_swl
l1-norm Wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain.
Initialization
- __reg_name__
‘l1swl’
- class corrct.regularizers.Regularizer_l12swl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, normalized: bool = False, min_approx: bool = True)[source]
Bases:
corrct.regularizers.Regularizer_swl
l1-norm Wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain.
Initialization
- __reg_name__
‘l12swl’
- class corrct.regularizers.Regularizer_Hub_swl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, normalized: bool = False, min_approx: bool = True, huber_size: Optional[int] = None)[source]
Bases:
corrct.regularizers.Regularizer_swl
l1-norm Wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain.
Initialization
- __reg_name__
‘Hubswl’
- class corrct.regularizers.Regularizer_dwl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, min_approx: bool = True, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1())[source]
Bases:
corrct.regularizers.BaseRegularizer
Base decimated wavelet regularizer. It can be used to promote sparse reconstructions in the wavelet domain.
Initialization
- __reg_name__
‘dwl’
- class corrct.regularizers.Regularizer_l1dwl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_dwl
l1-norm decimated wavelet regularizer. It can be used to promote sparse reconstructions.
Initialization
- __reg_name__
‘l1dwl’
- class corrct.regularizers.Regularizer_l12dwl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_dwl
l1-norm decimated wavelet regularizer. It can be used to promote sparse reconstructions.
Initialization
- __reg_name__
‘l12dwl’
- class corrct.regularizers.Regularizer_Hub_dwl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, huber_size: Optional[int] = None)[source]
Bases:
corrct.regularizers.Regularizer_dwl
l1-norm decimated wavelet regularizer. It can be used to promote sparse reconstructions.
Initialization
- __reg_name__
‘Hubdwl’
- class corrct.regularizers.BaseRegularizer_med(weight: Union[float, numpy.typing.NDArray], filt_size: int = 3, upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1())[source]
Bases:
corrct.regularizers.BaseRegularizer
Median filter regularizer base class. It can be used to promote filtered reconstructions.
Initialization
- __reg_name__
‘med’
- class corrct.regularizers.Regularizer_l1med(weight: Union[float, numpy.typing.NDArray], filt_size: int = 3)[source]
Bases:
corrct.regularizers.BaseRegularizer_med
l1-norm median filter regularizer. It can be used to promote filtered reconstructions.
Initialization
- __reg_name__
‘l1med’
- class corrct.regularizers.Regularizer_l2med(weight: Union[float, numpy.typing.NDArray], filt_size: int = 3)[source]
Bases:
corrct.regularizers.BaseRegularizer_med
l2-norm median filter regularizer. It can be used to promote filtered reconstructions.
Initialization
- __reg_name__
‘l2med’
- class corrct.regularizers.Regularizer_fft(weight: Union[float, numpy.typing.NDArray], ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, fft_filter: str = 'exp', upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l12())[source]
Bases:
corrct.regularizers.BaseRegularizer
Fourier regularizer. It can be used to promote sparse reconstructions in the Fourier domain.
Initialization
- __reg_name__
‘fft’
- class corrct.regularizers.Regularizer_TNV(weight: Union[float, numpy.typing.NDArray], ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_mode: str = 'edge', upd_mask: Optional[numpy.typing.NDArray] = None, spectral_norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1(), x_ref: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_Grad
Total Nuclear Variation (TNV) regularizer.
It can be used to promote piece-wise constant reconstructions, for multi-channel volumes.
Initialization
- __reg_name__
‘TNV’
- class corrct.regularizers.Regularizer_VTV(weight: Union[float, numpy.typing.NDArray], ndims: int = 2, pwise_der_norm: Union[int, float] = 2, pwise_chan_norm: Union[int, float] = np.inf, x_ref: Optional[numpy.typing.NDArray] = None, upd_mask: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_Grad
Vectorial Total Variation (VTV) regularizer.
It can be used to promote piece-wise constant reconstructions, for multi-channel volumes.
Initialization
- __reg_name__
‘VTV’
- class corrct.regularizers.Regularizer_lnswl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, normalized: bool = False, min_approx: bool = True, spectral_norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1(), x_ref: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_l1swl
Nuclear-norm Wavelet regularizer.
It can be used to promote compressed multi-channel reconstructions.
Initialization
- __reg_name__
‘lnswl’
- class corrct.regularizers.Regularizer_vl1wl(weight: Union[float, numpy.typing.NDArray], wavelet: str, level: int, ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, pad_on_demand: str = 'constant', upd_mask: Optional[numpy.typing.NDArray] = None, normalized: bool = False, min_approx: bool = True, pwise_lvl_norm: Union[int, float] = 1, pwise_chan_norm: Union[int, float] = np.inf, x_ref: Optional[numpy.typing.NDArray] = None)[source]
Bases:
corrct.regularizers.Regularizer_l1swl
l1-norm vectorial Wavelet regularizer. It can be used to promote compressed reconstructions.
Initialization
- __reg_name__
‘vl1wl’
- class corrct.regularizers.Regularizer_vSVD(weight: Union[float, numpy.typing.NDArray], ndims: int = 2, axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None, axis_channels: collections.abc.Sequence[int] = (0,), upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l1())[source]
Bases:
corrct.regularizers.BaseRegularizer
Regularizer based on the Singular Value Decomposition.
It can be used to promote similar reconstructions across different channels.
Initialization
- __reg_name__
‘vsvd’
- class corrct.regularizers.Constraint_LowerLimit(limit: Union[float, numpy.typing.NDArray], upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l2())[source]
Bases:
corrct.regularizers.BaseRegularizer
Lower limit constraint. It can be used to promote reconstructions in certain regions of solution space.
Initialization
- __reg_name__
‘lowlim’
- class corrct.regularizers.Constraint_UpperLimit(limit: Union[float, numpy.typing.NDArray], upd_mask: Optional[numpy.typing.NDArray] = None, norm: corrct.data_terms.DataFidelityBase = dt.DataFidelity_l2())[source]
Bases:
corrct.regularizers.BaseRegularizer
Upper limit constraint. It can be used to promote reconstructions in certain regions of solution space.
Initialization
- __reg_name__
‘uplim’