VPI - Vision Programming Interface

0.3.7 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.

For more details, consult the API reference.

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.410 ms0.0730 msn/a
640x4801920x1080u8linear 0.94 ms0.0737 msn/a
640x4801920x1080u8catmull 0.95 ms0.2193 msn/a
960x5401920x1080u8nearest 0.435 ms0.0757 msn/a
960x5401920x1080u8linear 1.00 ms0.0745 msn/a
960x5401920x1080u8catmull 1.03 ms0.2235 msn/a
1920x1080640x480u8nearest 0.202 ms0.0201 msn/a
1920x1080640x480u8linear 0.575 ms0.0298 msn/a
1920x1080640x480u8catmull 0.704 ms0.0467 msn/a
1280x960640x480u8nearest 0.196 ms0.0201 msn/a
1280x960640x480u8linear 0.155 ms0.0173 msn/a
1280x960640x480u8catmull 0.638 ms0.0432 msn/a
640x4801920x1080u16nearest 0.51 ms0.0926 msn/a
640x4801920x1080u16linear 0.67 ms0.0928 msn/a
640x4801920x1080u16catmull 0.9 ms0.2339 msn/a
960x5401920x1080u16nearest 0.529 ms0.0931 msn/a
960x5401920x1080u16linear 1.06 ms0.0914 msn/a
960x5401920x1080u16catmull 0.98 ms0.2394 msn/a
1920x1080640x480u16nearest 0.234 ms0.0321 msn/a
1920x1080640x480u16linear 0.59 ms0.0538 msn/a
1920x1080640x480u16catmull 0.625 ms0.0667 msn/a
1280x960640x480u16nearest 0.219 ms0.0251 msn/a
1280x960640x480u16linear 0.208 ms0.03037 msn/a
1280x960640x480u16catmull 0.570 ms0.0528 msn/a
Jetson TX2
inputoutputtypeinterp.CPUCUDAPVA
640x4801920x1080u8nearest 0.43 ms0.1996 msn/a
640x4801920x1080u8linear 1.058 ms0.1924 msn/a
640x4801920x1080u8catmull 2.44 ms0.555 msn/a
960x5401920x1080u8nearest 0.559 ms0.1999 msn/a
960x5401920x1080u8linear 1.19 ms0.195 msn/a
960x5401920x1080u8catmull 2.566 ms0.556 msn/a
1920x1080640x480u8nearest 0.267 ms0.0480 msn/a
1920x1080640x480u8linear 0.951 ms0.0593 msn/a
1920x1080640x480u8catmull 2.99 ms0.1058 msn/a
1280x960640x480u8nearest 0.228 ms0.0482 msn/a
1280x960640x480u8linear 0.102 ms0.0375 msn/a
1280x960640x480u8catmull 2.14 ms0.0966 msn/a
640x4801920x1080u16nearest 0.616 ms0.215 msn/a
640x4801920x1080u16linear 1.171 ms0.215 msn/a
640x4801920x1080u16catmull 2.1 ms0.552 msn/a
960x5401920x1080u16nearest 0.746 ms0.221 msn/a
960x5401920x1080u16linear 1.299 ms0.219 msn/a
960x5401920x1080u16catmull 2.96 ms0.559 msn/a
1920x1080640x480u16nearest 0.445 ms0.0796 msn/a
1920x1080640x480u16linear 1.055 ms0.114 msn/a
1920x1080640x480u16catmull 2.50 ms0.183 msn/a
1280x960640x480u16nearest 0.361 ms0.0536 msn/a
1280x960640x480u16linear 0.347 ms0.0716 msn/a
1280x960640x480u16catmull 2.54 ms0.127 msn/a
Jetson Nano
inputoutputtypeinterp.CPUCUDAPVA
640x4801920x1080u8nearest 0.799 ms0.5540 msn/a
640x4801920x1080u8linear 2.106 ms0.5289 msn/a
640x4801920x1080u8catmull 3.92 ms1.5413 msn/a
960x5401920x1080u8nearest 0.941 ms0.5541 msn/a
960x5401920x1080u8linear 2.274 ms0.5259 msn/a
960x5401920x1080u8catmull 4.26 ms1.545 msn/a
1920x1080640x480u8nearest 0.279 ms0.0981 msn/a
1920x1080640x480u8linear 1.234 ms0.1188 msn/a
1920x1080640x480u8catmull 2.88 ms0.2638 msn/a
1280x960640x480u8nearest 0.2705 ms0.0910 msn/a
1280x960640x480u8linear 0.107 ms0.0795 msn/a
1280x960640x480u8catmull 2.296 ms0.2506 msn/a
640x4801920x1080u16nearest 0.999 ms0.5518 msn/a
640x4801920x1080u16linear 2.111 ms0.532 msn/a
640x4801920x1080u16catmull 3.350 ms1.522 msn/a
960x5401920x1080u16nearest 1.106 ms0.552 msn/a
960x5401920x1080u16linear 2.334 ms0.533 msn/a
960x5401920x1080u16catmull 3.56 ms1.5287 msn/a
1920x1080640x480u16nearest 0.431 ms0.1429 msn/a
1920x1080640x480u16linear 1.313 ms0.224 msn/a
1920x1080640x480u16catmull 2.03 ms0.362 msn/a
1280x960640x480u16nearest 0.353 ms0.1103 msn/a
1280x960640x480u16linear 0.333 ms0.1535 msn/a
1280x960640x480u16catmull 2.038 ms0.2907 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:206
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
VPIStream
struct VPIStreamImpl * VPIStream
A handle to a stream.
Definition: Types.h:177
vpiSubmitImageResampler
VPIStatus vpiSubmitImageResampler(VPIStream stream, VPIImage input, VPIImage output, VPIInterpolationType interpolationType, VPIBoundaryCond boundary)
Runs a generic resampling algorithm on a 2D image.
VPI_INTERP_LINEAR_FAST
@ VPI_INTERP_LINEAR_FAST
Fast linear interpolation.
Definition: Types.h:329
ImageResampler.h
VPIImage
struct VPIImageImpl * VPIImage
A handle to an image.
Definition: Types.h:183
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.
VPI_BOUNDARY_COND_ZERO
@ VPI_BOUNDARY_COND_ZERO
All pixels outside the image are considered to be zero.
Definition: Types.h:270
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.