VPI - Vision Programming Interface

0.2.0 Release

ImageConvert

Functions

VPIStatus vpiSubmitImageFormatConverter (VPIStream stream, VPIImage input, VPIImage output, VPIConversionPolicy convPolicy, float scale, float offset)
 Converts the image contents to the desired format, with optional scaling and offset. More...
 

Detailed Description

Converts the image contents to the desired format, with optional scaling and offset.

Function Documentation

◆ vpiSubmitImageFormatConverter()

VPIStatus vpiSubmitImageFormatConverter ( VPIStream  stream,
VPIImage  input,
VPIImage  output,
VPIConversionPolicy  convPolicy,
float  scale,
float  offset 
)

#include <vpi/algo/ImageFormatConverter.h>

Converts the image contents to the desired format, with optional scaling and offset.

The input and output types are inferred from the corresponding images passed as parameters. When scaling and offset are fractional, input is converted to 32-bit floating point prior conversion takes place. The formula that relates input and output pixels is:

\[ out(x,y) &=& clamp_{[min_{out},max_{out}]}(in(x,y)*\alpha + \beta) \]

where:

  • \(min_{out}\) and \(max_{out}\) are the minimum and maximum representable value by output image format. Exception is for floating point types, where limits are \([-\infty,\infty]\), i.e., no clamping is done.
  • \(\alpha\) is the scaling.
  • \(\beta\) is the offset.

float to integer conversion does returns the nearest integer number, rounding halfway cases away from zero.

Parameters
stream[in] a stream handle
input[in] input image
output[out] output image with the desied type
convPolicy[in] conversion policy to be used
scale[in] Scaling factor. Pass 1 for no scaling.
offset[in] Offset factor. Pass 0 for no offset.
Returns
an error code on failure else VPI_SUCCESS