phenotypic.correction.VisuShrinkCorrector#
- class phenotypic.correction.VisuShrinkCorrector(sigma: float | None = None, wavelet: str = 'db2', mode: Literal['soft', 'hard'] = 'soft', wavelet_levels: int | None = None, convert2ycbcr: bool = True)[source]
Bases:
ImageCorrectorDenoise all image components using a universal VisuShrink wavelet threshold.
Apply VisuShrink wavelet denoising to RGB (if present), grayscale, and detection matrix simultaneously. Unlike
VisuShrinkEnhancer, which modifies only the detection matrix, this corrector transforms all image representations to maintain cross-component consistency.For algorithm details, see What Enhancement Actually Does.
- Parameters:
sigma (float | None) – Noise standard deviation.
Noneauto-estimates from the image. For RGB, internal channel scaling is handled automatically. Default:None.wavelet (str) – Wavelet family name.
'db2'is general-purpose;'db4'preserves finer detail. Default:'db2'.mode (Literal['soft', 'hard']) – Thresholding mode.
'soft'produces smoother results;'hard'retains sharper edges. Default:'soft'.wavelet_levels (int | None) – Number of decomposition levels.
Noneuses the maximum minus three (automatic). Default:None.convert2ycbcr (bool) – Denoise RGB in YCbCr space so luminance and chrominance are handled separately, preserving colony color. Only applies when RGB data is present. Default:
True.
- Returns:
Input image with all components (RGB, gray, detect_mat) transformed by VisuShrink wavelet denoising.
- Return type:
Image
- Best For:
Quick, uniform denoising of raw plate scans for archival or publication where a single threshold is acceptable.
Removing scanner noise from all image components before downstream multi-channel analysis.
Plates with relatively uniform noise where adaptive subband thresholding is not necessary.
- Consider Also:
BayesShrinkCorrectorfor adaptive subband thresholds that preserve finer colony detail.StableDenoisefor variance-stabilized BM3D denoising when Poisson-Gaussian noise modelling is important.VisuShrinkEnhancerwhen only the detection matrix should be denoised (non-destructive to RGB and gray).
See also
/how_to/notebooks/correct_color_cast for combining denoising with color correction workflows.
Methods
Initialize VisuShrink corrector for all image components.
Applies the operation to an image, either in-place or on a copy.
Return (and optionally display) the root widget.
- __init__(sigma: float | None = None, wavelet: str = 'db2', mode: Literal['soft', 'hard'] = 'soft', wavelet_levels: int | None = None, convert2ycbcr: bool = True)[source]
Initialize VisuShrink corrector for all image components.
- Parameters:
sigma (float | None) – Noise level. None (default) auto-estimates. For RGB, denoise_wavelet handles internal scaling.
wavelet (str) – Wavelet type. ‘db2’ (default) is general-purpose.
mode (Literal['soft', 'hard']) – ‘soft’ (default) for smoothness.
wavelet_levels (int | None) – Levels. None = max-3.
convert2ycbcr (bool) – Denoise RGB in YCbCr space (True, default) for better color preservation. Only applies if RGB exists.
- __del__()
Automatically stop tracemalloc when the object is deleted.
- __getstate__()
Prepare the object for pickling by disposing of any widgets.
This ensures that UI components (which may contain unpickleable objects like input functions or thread locks) are cleaned up before serialization.
Note
This method modifies the object state by calling dispose_widgets(). Any active widgets will be detached from the object.
- apply(image: Image, inplace: bool = False) Image
Applies the operation to an image, either in-place or on a copy.
- Parameters:
image (Image) – The arr image to apply the operation on.
inplace (bool) – If True, modifies the image in place; otherwise, operates on a copy of the image.
- Returns:
The modified image after applying the operation.
- Return type:
Image
- widget(image: Image | None = None, show: bool = False) Widget
Return (and optionally display) the root widget.
- Parameters:
image (Image | None) – Optional image to visualize. If provided, visualization controls will be added to the widget.
show (bool) – Whether to display the widget immediately. Defaults to False.
- Returns:
The root widget.
- Return type:
ipywidgets.Widget
- Raises:
ImportError – If ipywidgets or IPython are not installed.