pixtreme.morphology
morphology
Morphological image operations.
__all__ = ('erosion', 'dilation', 'opening', 'closing', 'morphological_gradient', 'white_tophat', 'black_tophat')
module-attribute
black_tophat(frame, *, radius, shape='disk', border='replicate', border_value=None)
Return closing minus input to extract small dark detail.
Closing uses one radius, disk or square shape, and border for
its dilation and erosion. Border defaults to neutral replicate;
constant requires finite border_value. The fp32 subtraction is per
channel, preserves Frame metadata, and does not clamp scene values.
closing(frame, *, radius, shape='disk', border='replicate', border_value=None)
Dilate then erode an fp32 Frame with one shared structuring element.
radius is an int of at least 1; shape is disk or square.
Both stages use the same border, defaulting to neutral replicate;
constant requires finite border_value. The per-channel operation
preserves metadata and does not clamp negative values or values above 1.
dilation(frame, *, radius, shape='disk', border='replicate', border_value=None)
Replace every fp32 channel value with its structuring-element maximum.
radius is an int of at least 1. disk includes integer offsets whose
squared distance is at most radius ** 2; square includes the full
(2 * radius + 1) window. Border defaults to neutral replicate;
mirror reflects without repeating the edge, wrap is periodic, and
constant requires a finite border_value. Processing is independent
per channel, preserves Frame metadata, and does not clamp scene values.
erosion(frame, *, radius, shape='disk', border='replicate', border_value=None)
Replace every fp32 channel value with its structuring-element minimum.
radius is an int of at least 1. disk includes integer offsets whose
squared distance is at most radius ** 2; square includes the full
(2 * radius + 1) window. Border defaults to neutral replicate;
mirror reflects without repeating the edge, wrap is periodic, and
constant requires a finite border_value. Processing is independent
per channel, preserves Frame metadata, and does not clamp scene values.
morphological_gradient(frame, *, radius, shape='disk', border='replicate', border_value=None)
Return dilation minus erosion for an fp32 Frame.
Both extrema use the same radius, disk or square shape, and
border. Border defaults to neutral replicate; constant requires a
finite border_value. The subtraction is per channel, preserves Frame
metadata, and does not clamp negative values or values above 1.
opening(frame, *, radius, shape='disk', border='replicate', border_value=None)
Erode then dilate an fp32 Frame with one shared structuring element.
radius is an int of at least 1; shape is disk or square.
Both stages use the same border, defaulting to neutral replicate;
constant requires finite border_value. The per-channel operation
preserves metadata and does not clamp negative values or values above 1.
white_tophat(frame, *, radius, shape='disk', border='replicate', border_value=None)
Return input minus opening to extract small bright detail.
Opening uses one radius, disk or square shape, and border for
its erosion and dilation. Border defaults to neutral replicate;
constant requires finite border_value. The fp32 subtraction is per
channel, preserves Frame metadata, and does not clamp scene values.