phenotypic.enhance.AnscombeInverse#

class phenotypic.enhance.AnscombeInverse(gain: float = 1.0, mu: float = 0.0, sigma: float = 0.0, scale_factor: float | None = None)[source]

Bases: ImageEnhancer

Apply the inverse Generalized Anscombe Transform to restore original scale.

Converts variance-stabilized data back to the [0, 1] intensity range using the closed-form approximation of the exact unbiased inverse. Always pair with AnscombeForward in a pipeline, placing denoising operations between the forward and inverse transforms. Both must use identical parameter values.

For algorithm details, see What Enhancement Actually Does.

Parameters:
  • gain (float) – Camera gain in electrons per ADU. Must match the value used in AnscombeForward. Default: 1.0.

  • mu (float) – Read noise mean (baseline offset). Must match the forward transform. Default: 0.0.

  • sigma (float) – Read noise standard deviation. Must match the forward transform. Default: 0.0.

  • scale_factor (float | None) – Converts counts back to normalized [0,1] range. Must match the forward transform. If None (default), auto-detects from image metadata.

Returns:

Input image with detect_mat restored to [0, 1] intensity range. rgb and gray are unchanged.

Return type:

Image

Raises:

ValueError – If gain <= 0, sigma < 0, or scale_factor <= 0.

Best For:
  • Completing an Anscombe-based denoising pipeline.

  • Restoring biologically meaningful intensities after GAT-domain denoising.

  • Fluorescence or low-light plate workflows that require variance-stabilized processing.

Consider Also:

References

[1] F. J. Anscombe, “The transformation of Poisson, binomial and negative-binomial data,” Biometrika, vol. 35, no. 3/4, pp. 246–254, Dec. 1948.

[2] M. Makitalo and A. Foi, “Optimal inversion of the generalized Anscombe transformation for Poisson-Gaussian noise,” IEEE Trans. Image Process., vol. 22, no. 1, pp. 91–103, Jan. 2013.

See also

Tutorial 3: Enhancing Before Detection for a visual walkthrough of enhancement pipelines on plate images. What Enhancement Actually Does for background on variance-stabilizing transforms and denoising strategies.

Methods

__init__

apply

Applies the operation to an image, either in-place or on a copy.

widget

Return (and optionally display) the root widget.

__init__(gain: float = 1.0, mu: float = 0.0, sigma: float = 0.0, scale_factor: float | None = None)[source]
Parameters:
  • gain (float) – Camera gain in electrons per ADU. Must match the value used in AnscombeForward. Default 1.0.

  • mu (float) – Read noise mean. Must match the value used in AnscombeForward. Default 0.0.

  • sigma (float) – Read noise standard deviation. Must match the value used in AnscombeForward. Default 0.0.

  • scale_factor (float | None) – Converts counts back to normalized [0,1] range. Must match the value used in AnscombeForward. If None (default), auto-detects from image metadata.

__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, inplace=False)

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.