VPI - Vision Programming Interface

0.3.7 Release

Image Format Converter

Enumerations

enum  VPIConversionPolicy {
  VPI_CONVERSION_INVALID = 0,
  VPI_CONVERSION_CAST,
  VPI_CONVERSION_CLAMP
}
 Policy used when converting between image types. More...
 

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.

Enumeration Type Documentation

◆ VPIConversionPolicy

#include <vpi/Types.h>

Policy used when converting between image types.

Enumerator
VPI_CONVERSION_INVALID 

Invalid conversion.

VPI_CONVERSION_CAST 

Casts input to the output type.

Overflows and underflows are handled as per C specification, including situations of undefined behavior.

VPI_CONVERSION_CLAMP 

Clamps input to output's type range.

Overflows and underflows are mapped to the output type's maximum and minimum representable value, respectively. When output type is floating point, clamp behaves like cast.

Definition at line 380 of file Types.h.

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_{[\mathsf{min_{out}},\mathsf{max_{out}}]}(in(x,y)*\alpha + \beta) \]

where:

  • \(\mathsf{min_{out}}\) and \(\mathsf{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