pyflink.multimodal.operators.image_detect_subplot#
- image_detect_subplot(*columns, threshold=0.5, concurrency=None)[source]#
Create a subplot / mosaic detection UDF (OpenCV Hough-based).
Requires
pip install opencv-python-headless. This is a scalar UDF.Detects whether an image is a composite (mosaic / subplot / screenshot collage) by looking for strong horizontal/vertical grid lines. Images smaller than 20px on either axis always return
(False, 1)because the Hough line detector cannot accumulate enough votes at that resolution. Input must be a decoded image; encoded bytes raiseTypeError. Decode raw bytes first withimage_decode(on_error="null")when invalid inputs should become null. Corrupt decoded images still raise.is_valid_imagecan be used as a lightweight pre-filter but does not guarantee full pixel materialization.- Parameters
*columns – Optional image column(s). When provided, the UDF is applied directly instead of returning a factory.
threshold – Edge detection sensitivity in
[0, 1]. Higher values require stronger edges. Default0.5.concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF that returns an object with
is_subplot(bool) andcount(int).
Example:
>>> # As a reusable variable >>> subplot = image_detect_subplot(threshold=0.5) >>> df = df.with_column("subplot", subplot(col("img"))) >>> >>> # Inline >>> df = df.with_column("subplot", image_detect_subplot(col("img")))