phenotypic.enhance.MeijeringRidgeFilter#
- class phenotypic.enhance.MeijeringRidgeFilter(sigmas: Iterable[float] = (1, 2, 3), alpha: float | None = None, black_ridges: bool = False, mode: str = 'reflect', cval: float = 0)[source]
Bases:
ImageEnhancerEnhance fine ridge-like structures in
detect_matwith the Meijering neuriteness filter.Computes the Meijering neuriteness measure from Hessian matrix eigenvalues to highlight elongated, thread-like structures such as delicate filaments, thin wrinkles, and network-like features. More selective than
SatoRidgeFilterfor very fine, well-separated ridges.For algorithm details, see What Enhancement Actually Does.
- Parameters:
sigmas (Iterable[float]) – Sequence of standard deviations for Gaussian derivatives. Smaller values detect finer structures; larger values detect thicker features. Typical range:
(1, 2, 3)torange(1, 10). Default:(1, 2, 3).alpha (Optional[float]) – Shape parameter controlling linearity sensitivity.
None(default) uses-1/(ndim+1)which is-1/3for 2D images. Rarely requires manual tuning.black_ridges (bool) – If
True, detect dark ridges on bright background. IfFalse(default), detect bright ridges on dark background.mode (str) – Boundary handling. Accepted values:
'constant','reflect','wrap','nearest','mirror'. Default:'reflect'.cval (float) – Fill value when
mode='constant'. Default: 0.
- Returns:
Input image with
detect_matreplaced by the Meijering neuriteness response map.rgbandgrayare unchanged.- Return type:
Image
- Best For:
Delicate filamentous structures too thin for standard detection (actinomycetes, fungal hyphae, bacterial networks).
Fine wrinkles, grooves, or network features in biofilms.
Sparse mycelial networks or bacterial filaments that require sensitive ridge detection.
- Consider Also:
SatoRidgeFilterfor thicker, continuous tubular structures with less sensitivity to parameter tuning.HessianFilterfor combined edge and ridge detection with blob sensitivity control.CoherenceEnhancingDiffusionfor enhancing directional structures via anisotropic smoothing before ridge detection.
See also
Tutorial 3: Enhancing Before Detection for a visual walkthrough of ridge enhancement on plate images. What Enhancement Actually Does for background on Hessian-based ridge detection methods.
Methods
Applies the operation to an image, either in-place or on a copy.
Return (and optionally display) the root widget.
- __init__(sigmas: Iterable[float] = (1, 2, 3), alpha: float | None = None, black_ridges: bool = False, mode: str = 'reflect', cval: float = 0)[source]
- Parameters:
sigmas (tuple | list) – Sequence of standard deviations for Gaussian derivatives. Smaller values detect finer features, larger values detect thicker structures. Default (1, 2, 3).
alpha (float | None) – Shape parameter controlling linearity sensitivity. Default None uses -1/(ndim+1), which for 2D images is -1/3. Unlikely to require manual tuning in practice.
black_ridges (bool) – If True, detect dark ridges (colonies) on bright background. If False, detect bright ridges on dark background. For agar plates with dark colonies on light background, use True. Default False.
mode (str) – How to handle image boundaries. Options: ‘constant’ (pad with cval), ‘reflect’ (mirror), ‘wrap’ (tile), ‘nearest’ (replicate edge), ‘mirror’ (symmetric mirror). Default ‘reflect’.
cval (float) – Fill value when mode=’constant’. Default 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.