VPI - Vision Programming Interface

0.4.4 Release

Rescale

Overview

The Rescale algorithm is used to scale 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 rescale function.
    2. Define the input image object.
      VPIImage input = /*...*/;
    3. Create an output image with the new required size and same format as input.
      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);
    4. Create the stream where the algorithm will be submitted for execution.
      VPIStream stream;
      vpiStreamCreate(0, &stream);
  2. Processing phase
    1. Submit the algorithm to the stream along with all parameters. It'll be executed by the CUDA algorithm.
    2. Optionally, wait until the processing is done.
      vpiStreamSync(stream);
  3. Cleanup phase
    1. Free resources held by the stream and the input and output images.

Consult the Rescale for a complete example.

For more details, consult the Rescale API reference.

Limitations and Constraints

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

All Backends

CPU

CUDA

VIC

PVA

  • Not implemented

Performance

For information on how to use the performance table below, see Algorithm Performance Tables.
Before comparing measurements, consult Comparing Algorithm Elapsed Times.
For further information on how performance was benchmarked, see Performance Measurement.

 - 

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.
vpiStreamCreate
VPIStatus vpiStreamCreate(uint32_t flags, VPIStream *stream)
Create a stream instance.
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
VPI_BACKEND_CUDA
@ VPI_BACKEND_CUDA
CUDA backend.
Definition: Types.h:91
VPIStream
struct VPIStreamImpl * VPIStream
A handle to a stream.
Definition: Types.h:190
Rescale.h
Declares functions that implement the Rescale algorithm.
vpiStreamDestroy
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
VPI_INTERP_LINEAR_FAST
@ VPI_INTERP_LINEAR_FAST
Fast linear interpolation.
Definition: Types.h:277
vpiImageCreate
VPIStatus vpiImageCreate(uint32_t width, uint32_t height, VPIImageFormat fmt, uint32_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
vpiImageDestroy
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
VPIImage
struct VPIImageImpl * VPIImage
A handle to an image.
Definition: Types.h:196
vpiImageGetSize
VPIStatus vpiImageGetSize(VPIImage img, uint32_t *width, uint32_t *height)
Get the image size in pixels.
vpiSubmitRescale
VPIStatus vpiSubmitRescale(VPIStream stream, VPIBackend backend, VPIImage input, VPIImage output, VPIInterpolationType interpolationType, VPIBoundaryCond boundary)
Changes the size and scale of a 2D image.
VPI_BOUNDARY_COND_ZERO
@ VPI_BOUNDARY_COND_ZERO
All pixels outside the image are considered to be zero.
Definition: Types.h:218
VPIImageFormat
VPIImageFormat
Pre-defined image formats.
Definition: ImageFormat.h:94
vpiImageGetType
VPIStatus vpiImageGetType(VPIImage img, VPIImageFormat *type)
Get the image format.