VPI - Vision Programming Interface

0.4.4 Release

Convert Image Format

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

Enumerations

enum  VPIConversionPolicy
 Policy used when converting between image types. More...
 

Functions

VPIStatus vpiSubmitConvertImageFormat (VPIStream stream, VPIBackend backend, 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 328 of file Types.h.

Function Documentation

◆ vpiSubmitConvertImageFormat()

VPIStatus vpiSubmitConvertImageFormat ( VPIStream  stream,
VPIBackend  backend,
VPIImage  input,
VPIImage  output,
VPIConversionPolicy  convPolicy,
float  scale,
float  offset 
)

#include <vpi/algo/ConvertImageFormat.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
[in]streamA stream handle where the operation will be queued into.
[in]backendThe backend that will execute the algorithm.
[in]inputInput image to be converted.
[out]outputOutput image where result will be written to, with the desired type.
[in]convPolicyConversion policy to be used.
[in]scaleScaling factor. Pass 1 for no scaling.
[in]offsetOffset factor. Pass 0 for no offset.
Returns
an error code on failure else VPI_SUCCESS