VPI - Vision Programming Interface

0.2.0 Release

Image Resampler

Overview

The Image Resampler algorithm is used to rescale the input image by means of resampling its content to make it conform to the output image dimensions.

No pre-filtering is applied, it's expected that the input content doesn't have frequencies higher than the Nyquist limit to avoid aliasing artifacts when downsampling.

Several interpolation methods are available, allowing trade-offs between quality and performance.

Input Factor Output

\begin{align*} f_x &= 2/3 \\[5pt] f_y &= 3/2 \end{align*}

Implementation

For every output pixel, calculate the corresponding input pixel using the formula:

\[ \mathit{out}[x,y] = P(f_x x, f_y y) \]

where P depends on the interpolation method used.

Sampling operation considers that whole coordinates fall on pixel center.

Usage

  1. Initialization phase
    1. Include the header that defines the needed functions and structures.
    2. Define the stream on which the algorithm will be executed and the input image.
      VPIStream stream = /*...*/;
      VPIImage input = /*...*/;
    3. Create an output image with the required size and matching image type.
      uint32_t w, h;
      vpiImageGetSize(input, &w, &h);
      vpiImageGetType(input, &type);
      VPIImage output;
      vpiImageCreate(w * 2 / 3.0f, h * 3 / 2.0f, type, 0, &output);
  2. Processing phase
    1. Submit the algorithm to the stream along with all parameters.
    2. Optionally, wait until the processing is done.
      vpiStreamSync(stream);

Consult the Image Resample for a complete example.

Limitations and Constraints

Constraints for specific backends supersede the ones specified for all backends.

All Backends

PVA

  • Not implemented

Performance

For further information on how performance was benchmarked, see Performance Measurement.

Jetson AGX Xavier
inputoutputtypeinterp.CPUCUDAPVA
640x4801920x1080u8nearest 0.407 ms0.0760 msn/a
640x4801920x1080u8linear 0.92 ms0.0751 msn/a
640x4801920x1080u8catmull 0.99 ms0.2217 msn/a
960x5401920x1080u8nearest 0.43 ms0.0776 msn/a
960x5401920x1080u8linear 0.96 ms0.0759 msn/a
960x5401920x1080u8catmull 1.03 ms0.2264 msn/a
1920x1080640x480u8nearest 0.199 ms0.0495 msn/a
1920x1080640x480u8linear 0.58 ms0.0483 msn/a
1920x1080640x480u8catmull 0.69 ms0.0486 msn/a
1280x960640x480u8nearest 0.190 ms0.0480 msn/a
1280x960640x480u8linear 0.151 ms0.039 msn/a
1280x960640x480u8catmull 0.624 ms0.0474 msn/a
640x4801920x1080u16nearest 0.51 ms0.0937 msn/a
640x4801920x1080u16linear 1.0 ms0.0936 msn/a
640x4801920x1080u16catmull 1.21 ms0.2389 msn/a
960x5401920x1080u16nearest 0.596 ms0.0948 msn/a
960x5401920x1080u16linear 1.10 ms0.0942 msn/a
960x5401920x1080u16catmull 1.1 ms0.2431 msn/a
1920x1080640x480u16nearest 0.25 ms0.0465 msn/a
1920x1080640x480u16linear 0.584 ms0.0535 msn/a
1920x1080640x480u16catmull 0.67 ms0.0665 msn/a
1280x960640x480u16nearest 0.234 ms0.0464 msn/a
1280x960640x480u16linear 0.206 ms0.0385 msn/a
1280x960640x480u16catmull 0.581 ms0.0531 msn/a
Jetson TX2
inputoutputtypeinterp.CPUCUDAPVA
640x4801920x1080u8nearest 0.430 ms0.1986 msn/a
640x4801920x1080u8linear 1.061 ms0.191 msn/a
640x4801920x1080u8catmull 2.51 ms0.554 msn/a
960x5401920x1080u8nearest 0.495 ms0.199 msn/a
960x5401920x1080u8linear 1.151 ms0.193 msn/a
960x5401920x1080u8catmull 2.587 ms0.557 msn/a
1920x1080640x480u8nearest 0.236 ms0.128 msn/a
1920x1080640x480u8linear 0.954 ms0.1266 msn/a
1920x1080640x480u8catmull 2.92 ms0.127 msn/a
1280x960640x480u8nearest 0.231 ms0.1280 msn/a
1280x960640x480u8linear 0.093 ms0.1086 msn/a
1280x960640x480u8catmull 2.11 ms0.1263 msn/a
640x4801920x1080u16nearest 0.619 ms0.213 msn/a
640x4801920x1080u16linear 1.182 ms0.215 msn/a
640x4801920x1080u16catmull 2.11 ms0.554 msn/a
960x5401920x1080u16nearest 0.722 ms0.218 msn/a
960x5401920x1080u16linear 1.30 ms0.216 msn/a
960x5401920x1080u16catmull 2.38 ms0.560 msn/a
1920x1080640x480u16nearest 0.420 ms0.1251 msn/a
1920x1080640x480u16linear 1.040 ms0.1279 msn/a
1920x1080640x480u16catmull 2.47 ms0.180 msn/a
1280x960640x480u16nearest 0.371 ms0.1277 msn/a
1280x960640x480u16linear 0.353 ms0.108 msn/a
1280x960640x480u16catmull 2.43 ms0.1286 msn/a
Jetson Nano
inputoutputtypeinterp.CPUCUDAPVA
640x4801920x1080u8nearest 0.778 ms0.5543 msn/a
640x4801920x1080u8linear 2.092 ms0.5288 msn/a
640x4801920x1080u8catmull 3.953 ms1.542 msn/a
960x5401920x1080u8nearest 0.930 ms0.5542 msn/a
960x5401920x1080u8linear 2.287 ms0.5265 msn/a
960x5401920x1080u8catmull 4.35 ms1.5471 msn/a
1920x1080640x480u8nearest 0.2712 ms0.142 msn/a
1920x1080640x480u8linear 1.219 ms0.145 msn/a
1920x1080640x480u8catmull 2.89 ms0.2616 msn/a
1280x960640x480u8nearest 0.2683 ms0.143 msn/a
1280x960640x480u8linear 0.1034 ms0.113 msn/a
1280x960640x480u8catmull 2.230 ms0.2487 msn/a
640x4801920x1080u16nearest 0.981 ms0.5520 msn/a
640x4801920x1080u16linear 2.144 ms0.530 msn/a
640x4801920x1080u16catmull 3.232 ms1.522 msn/a
960x5401920x1080u16nearest 1.093 ms0.551 msn/a
960x5401920x1080u16linear 2.299 ms0.533 msn/a
960x5401920x1080u16catmull 3.51 ms1.528 msn/a
1920x1080640x480u16nearest 0.4167 ms0.146 msn/a
1920x1080640x480u16linear 1.302 ms0.2222 msn/a
1920x1080640x480u16catmull 2.07 ms0.360 msn/a
1280x960640x480u16nearest 0.355 ms0.143 msn/a
1280x960640x480u16linear 0.3592 ms0.1503 msn/a
1280x960640x480u16catmull 1.930 ms0.2879 msn/a

References

  • Daniel Ruijters, Bart M. ter Romeny, Paul Suetens (2008) "Efficient GPU-Based Texture Interpolation using Uniform B-Spline"
    Journal of Graphics Tools, 13:4 61-69.
VPIImageType
VPIImageType
Image formats.
Definition: Types.h:190
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
vpiSubmitImageResampler
VPIStatus vpiSubmitImageResampler(VPIStream stream, VPIImage input, VPIImage output, VPIInterpolationType interpolationType, VPIBoundaryCond boundary)
Runs a generic resampling algorithm on a 2D image.
ImageResampler.h
VPIImage
struct VPIImageImpl * VPIImage
Definition: Types.h:170
vpiImageGetSize
VPIStatus vpiImageGetSize(VPIImage img, uint32_t *width, uint32_t *height)
Get the image size in pixels.
vpiImageGetType
VPIStatus vpiImageGetType(VPIImage img, VPIImageType *type)
Get the image type.
vpiImageCreate
VPIStatus vpiImageCreate(uint32_t width, uint32_t height, VPIImageType type, uint32_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
VPI_BOUNDARY_COND_ZERO
@ VPI_BOUNDARY_COND_ZERO
All pixels outside the image are considered to be zero.
Definition: Types.h:251
VPIStream
struct VPIStreamImpl * VPIStream
Definition: Types.h:164
VPI_INTERP_LINEAR_FAST
@ VPI_INTERP_LINEAR_FAST
Fast linear interpolation.
Definition: Types.h:307