14 lines
576 B
Python
14 lines
576 B
Python
from typing import Iterable
|
|
|
|
from funcy import rpartial
|
|
|
|
from image_prediction.image_extractor.extractor import ImageMetadataPair
|
|
from image_prediction.stitching.merging import merge_along_both_axes, no_new_merges
|
|
from image_prediction.utils.generic import until
|
|
|
|
|
|
def stitch_pairs(pairs: Iterable[ImageMetadataPair], tolerance=0) -> Iterable[ImageMetadataPair]:
|
|
"""Given a collection of image-metadata pairs from the same pages, combines all pairs that constitute adjacent
|
|
images."""
|
|
return until(no_new_merges, rpartial(merge_along_both_axes, tolerance), pairs)
|