The algorithm writes in the destination image a pixel read in the source image in a position determined by the map image. For each destination pixel, the algorithm reads a map value at its corresponding position using the map interpolation type. The map value is either an absolute position \( (x, y) \), denormalized (when using zero in algorithm flags) or normalized (when setting VPI_NORMALIZED_MAP in flags), or a relative offset (when also setting VPI_RELATIVE_MAP) \( (dx, dy) \) from the normalized destination coordinate to a normalized position in the source (see illustration below). The pixel at that source position is fetched from source and stored at the destination position. The sampling of map values and source pixels is controlled by map and source interpolation types and also by algorithm flags. By using VPI_SAMPLING_ALIGNED_TO_CORNER in flags, the sampling occurs at the top-left corner of the pixels instead of the pixel center.
The illustration above explains how the dynamic remap algorithm works. All three images (source, map and destination) can have different sizes. The destination image controls the sampling in the map, i.e. each pixel in destination samples one pixel in the map by normalizing the destination coordinate and using the map interpolation type.
The map stores control points as two floating-point coordinates (see VPI_IMAGE_FORMAT_2F32 and VPIKeypointF32) as either \( (x, y) \) or \( (dx, dy) \). Absolute coordinates \( (x, y) \) are direct pixel positions in the source image. Relative coordinates \( (dx, dy) \) are delta differences that will be added to the map current position to yield the target source position to fetch the pixel from. When using relative map, it is required to use normalized map as well.
The images above shows an example of relative and normalized mapping, using bi-cubic (see VPI_INTERP_CATMULL_ROM) map interpolation type. Using these parameters, a simple \( 2x2 \) map is capable of remapping the source image into the destination image. Furthermore, both the map and source images can be modified in subsequent calls of the algorithm, for example during video frames or panorama stiching.
C API functions
For list of limitations, constraints and backends that implements the algorithm, consult reference documentation of the following functions:
Generate a custom mapping to warp a fisheye image into a more regular image. The map image stores the control points, corresponding to normalized relative offsets.