VPI - Vision Programming Interface

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

References

VPIImageType
VPIImageType
Image formats.
Definition: Types.h:172
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:153
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
All pixels outside the image are considered to be zero.
Definition: Types.h:204
VPIStream
struct VPIStreamImpl * VPIStream
Definition: Types.h:147
VPI_INTERP_LINEAR_FAST
Fast linear interpolation.
Definition: Types.h:258