phenotypic.enhance.AnscombeForward#

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

Bases: ImageEnhancer

Apply the forward Generalized Anscombe Transform for variance stabilization.

Converts Poisson-Gaussian noise into approximately Gaussian noise by applying a variance-stabilizing square-root transformation to detect_mat. After this transform, standard Gaussian denoisers (wavelets, BM3D, bilateral filters) work effectively on the stabilized signal. Always pair with AnscombeInverse in a pipeline, with denoising operations between them; both must use identical parameter values.

For algorithm details, see What Enhancement Actually Does.

Parameters:
  • gain (float) – Camera gain in electrons per ADU. Typical range: 0.1–10.0. Default: 1.0.

  • mu (float) – Read noise mean (baseline offset). Typical range: 0.0–50.0. Default: 0.0.

  • sigma (float) – Read noise standard deviation. Set to 0 for pure Poisson noise. Typical range: 0.0–10.0. Default: 0.0.

  • scale_factor (float | None) – Converts normalized [0,1] data to counts. If None (default), auto-detects from image metadata: 255 for 8-bit, 65535 for 16-bit.

Returns:

Input image with detect_mat in variance-stabilized (sqrt-scaled) domain. rgb and gray are unchanged.

Return type:

Image

Raises:

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

Best For:
  • Low-light or fluorescence plate images with photon-counting noise.

  • Images from CCD/CMOS sensors where noise is Poisson-dominated.

  • Enabling Gaussian denoisers on data with signal-dependent noise.

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. Higher gain amplifies both signal and noise. Default 1.0 assumes unity gain.

  • mu (float) – Read noise mean (baseline offset). For calibrated cameras, typically near 0. Default 0.0.

  • sigma (float) – Read noise standard deviation. Set to 0 for pure Poisson noise. Increase for cameras with significant read noise (e.g., 1-5 for CCD sensors). Default 0.0.

  • scale_factor (float | None) – Converts normalized [0,1] data to counts. If None (default), auto-detects from image metadata. Set manually if auto-detection fails or for raw count data (use 1.0).

__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.