phenotypic.enhance.SetDetectMode#
- class phenotypic.enhance.SetDetectMode(mode: Literal['gray', 'red', 'green', 'blue', 'MinRGB', 'LabL', 'LabA', 'LabB', 'HsvS', 'HsvV', 'InvS'] = 'gray')[source]
Bases:
ImageOperationSwitch the detection matrix source channel mid-pipeline.
Resets
detect_matto a fresh copy of the chosen channel, discarding any enhancements applied so far. Useful when different pipeline stages need to operate on different color channels.For algorithm details, see What Enhancement Actually Does.
- Parameters:
mode (DetectMode) – Channel to use for the detection matrix. Accepted values:
'gray'(default),'red','green','blue','min_rgb'.- Returns:
Input image with
detect_modeanddetect_matupdated to the chosen channel.- Return type:
Image
- Best For:
Switching to a specific color channel (e.g., red) that provides better colony-background contrast.
Resetting enhancements mid-pipeline to start fresh on a different channel.
Plates where colonies are more visible in a single color channel than in grayscale.
- Consider Also:
ImageInverterwhen the issue is inverted polarity rather than channel selection.
See also
Tutorial 3: Enhancing Before Detection for a visual walkthrough of channel selection strategies.
Methods
__init__Applies the operation to an image, either in-place or on a copy.
Return (and optionally display) the root widget.
- __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=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.