#29588·opencv

[Feature] Add native batch overloads for remap

Author: ternausCreated Jul 24, 2026Updated Sep 28, 2026
Labelsfeaturecategory: imgproc

Problem

cv::remap and cv2.remap process one image per call. A Python application that applies the same dense geometric map to an (N, H, W, C) batch must loop over images and dispatch remap N times.

Dense remapping is common in augmentation, camera correction, and preprocessing. For small and medium images, a native batch call can schedule work across images and avoid repeated Python/C++ dispatch.

The OpenCV 5 imgproc roadmap already lists batch processing across most functions. This issue defines the batch contract for remap.

Requested API

Add a native CPU batch overload with two map modes:

  1. one (H, W) map_x/map_y pair shared by every image;
  2. one map pair per image for applications that need independent geometry.

A Python API could accept a contiguous NHWC array or a sequence of arrays:

python
result = cv2.remapBatch(
    images,
    map_x,
    map_y,
    interpolation=cv2.INTER_LINEAR,
    borderMode=cv2.BORDER_REFLECT_101,
)

For shared maps and homogeneous input, (N, H, W, C) should produce (N, map_height, map_width, C). The public call must avoid a Python-level per-image loop.

Correctness requirements

  • shared and per-image maps have documented, unambiguous shapes;
  • uint8 and float32 images;
  • 1, 3, 4, and 5+ channels wherever the corresponding single-image mode works;
  • all interpolation and border modes supported by single-image remap;
  • scalar border values and the same validation rules as single-image remap;
  • values equivalent to N independent calls, with documented floating-point tolerance;
  • explicit behavior for empty batches and mixed image shapes.

Performance acceptance

Compare one batch call with N single-image calls under the same thread settings. Report 256×256, 512×512, and 1024×1024 inputs; batch sizes 2, 4, 8, and 16; uint8/float32; and 1, 3, and 5 channels. Measure shared maps separately from per-image maps.

Downstream demand

AlbumentationsX applies one sampled distortion map to every image in a batch but currently loops in Python. albumentations-team/AlbumentationsX#14 tracks a native batch path for all BaseDistortion transforms.