pyflink.multimodal.operators.image_crop#
- image_crop(*columns, crop_coords=None, crop_type='center', crop_ratio=(0.8, 0.8), crop_size=None, concurrency=None)[source]#
Crop an image by coordinates, center ratio, or center size.
- Parameters
*columns – Optional image columns. When provided, the UDF is applied directly instead of returning a factory.
crop_coords – Absolute pixel box
(x1, y1, x2, y2). When provided,crop_typeis set to"coordinate"automatically. Regions outside the input image are padded with zero-valued pixels.crop_type – Crop strategy —
"center"(default),"ratio", or"coordinate"."center"cropscrop_sizepixels from the center (falls back tocrop_ratioifcrop_sizeisNone)."ratio"center-crops bycrop_ratio."coordinate"uses the absolute box fromcrop_coords.crop_ratio – Fraction of width and height to keep, as
(width_ratio, height_ratio). Values in(0, 1]. Default(0.8, 0.8).crop_size – Fixed center-crop output size
(width, height)in pixels. Only used whencrop_type="center".None(default) falls back tocrop_ratio.concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF producing decoded image values.
- Example::
>>> # As a reusable variable >>> crop = image_crop(crop_coords=(100, 100, 500, 500)) >>> df = df.with_columns("cropped", crop(col("img"))) >>> >>> # Inline >>> df = df.with_columns( ... "cropped", image_crop(col("img"), crop_coords=(100, 100, 500, 500)) ... )