pyflink.multimodal.operators.image_crop_black_border#
- image_crop_black_border(*columns, threshold=None, detect_algorithm='auto', black_threshold=None, edge_sensitivity=1.0, min_border_size=1, concurrency=None)[source]#
Detect and remove black borders from an image.
If every pixel is treated as border (e.g. an all-black image), the original decoded image value is returned unchanged.
- Parameters
*columns – Optional image columns. When provided, the UDF is applied directly instead of returning a factory.
threshold – Legacy alias for
black_threshold. Cannot be combined with an explicitblack_threshold.detect_algorithm – Detection strategy —
"auto"(default),"threshold","histogram", or"edge"."auto"tries threshold, histogram, and edge detection in order and uses the first effective crop box.black_threshold – Pixel luminance value (0-255) at or below which content is treated as black border. Default
10. Detection converts the image to 8-bit luminance first, so this scale applies even for L16/RGB16 inputs.edge_sensitivity – Sensitivity for the
"edge"detector, in[0.1, 2.0]. Higher values detect subtler borders. Default1.0.min_border_size – Minimum border width in pixels before a crop is applied. Default
1.concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF producing decoded image values.
- Example::
>>> # As a reusable variable >>> crop_border = image_crop_black_border(black_threshold=15) >>> df = df.with_columns("clean", crop_border(col("img"))) >>> >>> # Inline >>> df = df.with_columns("clean", image_crop_black_border(col("img"), black_threshold=15))