phenotypic.tools_.ClipControlMixin#

class phenotypic.tools_.ClipControlMixin[source]

Bases: object

Mixin for operations that need to control clipping behavior of inner operations.

Provides a method to create copies of ImageEnhancer or ImagePipeline instances with clipping disabled. This is useful for composite operations where an inner enhancer operates on non-normalized data (e.g., variance-stabilized values from the Generalized Anscombe Transform, typically in the range ~1-32).

The mixin uses duck typing to check for a clip attribute on operations. If an operation has clip=True, the _disable_clipping method will create a shallow copy with clip=False. This preserves the original operation unchanged while allowing the copy to operate without output clipping.

Example

Creating a clip-disabled copy of an enhancer:

>>> from phenotypic.tools_ import ClipControlMixin
>>> from phenotypic.enhance import BilateralDenoise
>>>
>>> enh = BilateralDenoise(sigma_spatial=5, clip=True)
>>> copied = ClipControlMixin._disable_clipping(enh)
>>> # Original unchanged, copy has clip=False
>>> enh.clip, copied.clip
(True, False)

Creating a clip-disabled copy of a pipeline:

>>> from phenotypic import ImagePipeline
>>> from phenotypic.enhance import GaussianBlur, BilateralDenoise
>>>
>>> pipeline = ImagePipeline([
...     GaussianBlur(sigma=1.0),
...     BilateralDenoise(sigma_spatial=5, clip=True)
... ])
>>> copied_pipe = ClipControlMixin._disable_clipping(pipeline)
>>> # Only BilateralDenoise has clip attribute, so only it is affected
>>> # _ops is a dict with operation names as keys
>>> list(copied_pipe._ops.values())[1].clip
False

Methods

__init__