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. Corrupt or undecodable images raise; useis_valid_imagefirst when invalid inputs should be filtered instead of failing the task.- 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")))