phenotypic.enhance.LaplaceEnhancer#
- class phenotypic.enhance.LaplaceEnhancer(kernel_size: int | None = 3, mask: numpy.ndarray | None = None)[source]#
Bases:
ImageEnhancerLaplacian edge enhancement for colony boundaries.
Applies a Laplacian operator that responds to rapid intensity changes and highlights edges. In agar plate images, this can delineate colony margins and ring-like features, improving contour detection or watershed seeds.
Use cases (agar plates): - Emphasize colony edges prior to edge-based segmentation or as a cue for
separating touching colonies.
Detect ring patterns around colonies (e.g., swarming fronts) for phenotyping.
Tuning and effects: - kernel_size: Larger kernels produce a smoother, more global edge response
and can suppress small noise; smaller kernels capture fine edges but may amplify noise and agar texture.
mask: Restrict processing to the plate region to avoid dish edge glare or labels. A binary mask focusing on the circular plate is often useful.
Caveats: - Laplacian is sensitive to noise; consider a light GaussianBlur first. - May enhance non-biological artifacts (scratches, dust). Combine with masking
or artifact removal if necessary.
- Parameters:
kernel_size (Optional[int]) – Size of the Laplacian kernel controlling edge scale; smaller captures fine edges, larger smooths noise.
mask (Optional[numpy.ndarray]) – Optional boolean/0-1 mask to limit the operation to specific regions (e.g., the plate area).
Methods
Applies the operation to an image, either in-place or on a copy.
Drop references to the UI widgets.
Push internal state into widgets.
Return (and optionally display) the root widget.
- __init__(kernel_size: int | None = 3, mask: numpy.ndarray | None = None)[source]#
- Parameters:
kernel_size (Optional[int]) – Controls the edge scale. Smaller values pick up fine edges but increase noise sensitivity; larger values smooth noise and emphasize broader boundaries.
mask (Optional[np.ndarray]) – Boolean/0-1 mask to limit processing to regions of interest (e.g., the circular plate), reducing artifacts from dish rims or labels.
- __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.
- widget(image: Image | None = None, show: bool = False) Widget#
Return (and optionally display) the root widget.
- Parameters:
- Returns:
The root widget.
- Return type:
ipywidgets.Widget
- Raises:
ImportError – If ipywidgets or IPython are not installed.