phenotypic.enhance.MultiscaleLoGEnhancer#
- class phenotypic.enhance.MultiscaleLoGEnhancer(min_radius: float = 3.0, max_radius: float = 12.0, num_scales: int = 12)[source]
Bases:
ImageEnhancerEnhance blob-like colonies in
detect_matwith scale-normalised Laplacian of Gaussian.Applies LoG filtering across a geometric series of Gaussian sigmas and returns the maximum response at each pixel. Bright blob-like structures (colonies, inocula, droplets) produce strong peaks regardless of size, making this a robust preprocessing step before thresholding or GMM-based segmentation.
For algorithm details, see What Enhancement Actually Does.
- Parameters:
min_radius (float) – Smallest target blob radius in pixels. Blobs smaller than this produce weaker responses. Typical range: 1.0–5.0 at 512x768 resolution. Scale proportionally for higher resolutions. Default: 3.0.
max_radius (float) – Largest target blob radius in pixels. Blobs larger than this also produce weaker responses. Typical range: 8.0–50.0 at 512x768 resolution. Default: 12.0.
num_scales (int) – Number of logarithmically spaced sigma values. More scales improve size discrimination at higher compute cost. Typical range: 4–20. Default: 12.
- Returns:
Input image with
detect_matreplaced by the scale-normalised LoG response map.rgbandgrayare unchanged.- Return type:
Image
- Raises:
ValueError – If
min_radius<= 0,min_radius>=max_radius, ornum_scales< 1.
- Best For:
Mixed-size colonies on mature plates where small emerging and large mature colonies must both be detected.
Sparse inoculation spots that are faint and nearly invisible against the agar background.
Low-contrast or shadowed regions where LoG emphasizes blob structure over absolute intensity.
Preprocessing before thresholding to sharpen blob boundaries and suppress uneven illumination.
- Consider Also:
SatoRidgeFilterfor elongated or filamentous structures where LoG’s isotropic assumption is a poor fit.LaplaceEnhancerfor simpler single-scale edge detection.SubtractGaussianwhen the primary issue is illumination gradients rather than blob enhancement.
See also
Tutorial 3: Enhancing Before Detection for a visual walkthrough of blob enhancement on plate images. What Enhancement Actually Does for background on scale-space blob detection and LoG theory.
Methods
Initialize MultiscaleLoGEnhancer with radius range and scale density.
Applies the operation to an image, either in-place or on a copy.
Return (and optionally display) the root widget.
- __init__(min_radius: float = 3.0, max_radius: float = 12.0, num_scales: int = 12)[source]
Initialize MultiscaleLoGEnhancer with radius range and scale density.
- Parameters:
min_radius (float) – Smallest target blob radius in pixels. The corresponding Gaussian sigma is
min_radius / sqrt(2). Blobs smaller than this radius produce weaker LoG responses. Typical range: 1.0–5.0 pixels at 512×768 resolution. Default: 3.0.max_radius (float) – Largest target blob radius in pixels. The corresponding Gaussian sigma is
max_radius / sqrt(2). Blobs larger than this radius also produce weaker responses. Typical range: 8.0–50.0 pixels at 512×768 resolution. Default: 12.0.num_scales (int) – Number of logarithmically spaced sigma values between
min_radius / sqrt(2)andmax_radius / sqrt(2). Controls size-discrimination resolution. Larger values give finer blob size resolution but increase computation (one LoG evaluation per scale). Typical range: 4–20. Default: 12.
- Raises:
ValueError – If min_radius <= 0, min_radius >= max_radius, or num_scales < 1.
- __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.