phenotypic.sdk_.ClipControlMixin#
- class phenotypic.sdk_.ClipControlMixin[source]#
Bases:
objectMixin 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.sdk_ import ClipControlMixin >>> from phenotypic.enhance import LocalEdgeDenoise >>> >>> enh = LocalEdgeDenoise(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, LocalEdgeDenoise >>> >>> pipeline = ImagePipeline(pipe_cfgs=[ ... GaussianBlur(sigma=1.0), ... LocalEdgeDenoise(sigma_spatial=5, clip=True) ... ]) >>> copied_pipe = ClipControlMixin._disable_clipping(pipeline) >>> # Only LocalEdgeDenoise 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__