phenotypic.enhance.SobelFilter#
- class phenotypic.enhance.SobelFilter[source]#
Bases:
ImageEnhancerSobel edge filter to highlight colony boundaries.
Computes the gradient magnitude using the Sobel operator to emphasize edges (rapid intensity changes). On agar plate images, this highlights colony perimeters and helps downstream steps that rely on edge strength (e.g., contour finding, watershed seeds, or boundary-based scoring).
Use cases (agar plates): - Emphasize colony outlines before contour detection or watershed. - Separate touching colonies when combined with a distance or marker-based
segmentation strategy.
Guidance: - Consider light smoothing with GaussianBlur beforehand to suppress noise;
Sobel is sensitive to high-frequency artifacts (dust, texture).
Caveats: - Output is an edge map, not a background-corrected image. Use in tandem
with background removal or thresholding for full segmentation.
Strong illumination gradients can still produce spurious edges; correct background first if needed.
Methods
__init__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.
- __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.