Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

Functions for Affine Warp of images. More...

Enumerations

enum  SimdWarpAffineFlags {
  SimdWarpAffineDefault = 0 ,
  SimdWarpAffineChannelByte = 0 ,
  SimdWarpAffineChannelMask = 1 ,
  SimdWarpAffineInterpNearest = 0 ,
  SimdWarpAffineInterpBilinear = 2 ,
  SimdWarpAffineInterpMask = 2 ,
  SimdWarpAffineBorderConstant = 0 ,
  SimdWarpAffineBorderTransparent = 4 ,
  SimdWarpAffineBorderMask = 4
}
 

Functions

SIMD_API void * SimdWarpAffineInit (size_t srcW, size_t srcH, size_t srcS, size_t dstW, size_t dstH, size_t dstS, size_t channels, const float *mat, SimdWarpAffineFlags flags, const uint8_t *border)
 Creates wrap affine context. More...
 
SIMD_API void SimdWarpAffineRun (const void *context, const uint8_t *src, uint8_t *dst)
 Performs warp affine for current image. More...
 
template<template< class > class A>
SIMD_INLINE void WarpAffine (const View< A > &src, const float *mat, View< A > &dst, SimdWarpAffineFlags flags=(SimdWarpAffineFlags)(SimdWarpAffineChannelByte|SimdWarpAffineInterpBilinear|SimdWarpAffineBorderConstant), const uint8_t *border=NULL)
 Performs warp affine for current image. More...
 
SIMD_INLINE bool InvertAffineTransform (const float *src, float *dst)
 Performs inversion of warp affine transform matrix. More...
 

Detailed Description

Functions for Affine Warp of images.

Enumeration Type Documentation

◆ SimdWarpAffineFlags

Describes Warp Affine flags. This type used in function SimdWarpAffineInit.

Enumerator
SimdWarpAffineDefault 

Default Warp Affine flags.

SimdWarpAffineChannelByte 

8-bit integer channel type.

SimdWarpAffineChannelMask 

Bit mask of channel type.

SimdWarpAffineInterpNearest 

Nearest pixel interpolation method.

SimdWarpAffineInterpBilinear 

Bilinear pixel interpolation method.

SimdWarpAffineInterpMask 

Bit mask of pixel interpolation options.

SimdWarpAffineBorderConstant 

Nearest pixel interpolation method.

SimdWarpAffineBorderTransparent 

Bilinear pixel interpolation method.

SimdWarpAffineBorderMask 

Bit mask of pixel interpolation options.

Function Documentation

◆ SimdWarpAffineInit()

void * SimdWarpAffineInit ( size_t  srcW,
size_t  srcH,
size_t  srcS,
size_t  dstW,
size_t  dstH,
size_t  dstS,
size_t  channels,
const float *  mat,
SimdWarpAffineFlags  flags,
const uint8_t *  border 
)

Creates wrap affine context.

Simplified, then warp affine performs next transformation for every pixel:

dst[x, y] = src[x * mat[0][0] + y * mat[0][1] + mat[0][2], x * mat[1][0] + y * mat[1][1] + mat[1][2]];

An using example (for BGR image):

float mat[2][3] = { { 1.0f, -1.0f, 0.0f }, { 1.0f, 1.0f, 0.0f } };
SimdWarpAffineFlags flags = SimdWarpAffineChannelByte | SimdWarpAffineInterpBilinear | SimdWarpAffineBorderConstant;
void* context = SimdWarpAffineInit(srcW, srcH, srcS, dstW, dstH, dstS, 3, mat, flags, NULL);
if (context)
{
     SimdWarpAffineRun(context, src, dst);
     SimdRelease(context);
}
Note
This function has a C++ wrapper Simd::WarpAffine(const View& src, const float * mat, View& dst, SimdWarpAffineFlags flags = SimdWarpAffineInterpBilinear | SimdWarpAffineBorderConstant, const uint8_t* border = NULL).
Parameters
[in]srcW- a width of input image.
[in]srcH- a height of input image.
[in]srcS- a row size (in bytes) of the input image.
[in]dstW- a width of output image.
[in]dstH- a height of output image.
[in]dstS- a row size (in bytes) of the output image.
[in]channels- a channel number of input and output image. Its value must be in range [1..4].
[in]mat- a pointer to 2x3 matrix with coefficients of affine warp.
[in]flags- a flags of algorithm parameters.
[in]border- a pointer to to the array with color of border. The size of the array must be equal to channels. It parameter is actual for SimdWarpAffineBorderConstant flag. It can be NULL.
Returns
a pointer to warp affine context. On error it returns NULL. This pointer is used in functions SimdWarpAffineRun. It must be released with using of function SimdRelease.

◆ SimdWarpAffineRun()

void SimdWarpAffineRun ( const void *  context,
const uint8_t *  src,
uint8_t *  dst 
)

Performs warp affine for current image.

Note
This function has a C++ wrapper Simd::WarpAffine(const View& src, const float * mat, View& dst, SimdWarpAffineFlags flags = SimdWarpAffineInterpBilinear | SimdWarpAffineBorderConstant, const uint8_t* border = NULL).
Parameters
[in]context- a warp affine context. It must be created by function SimdWarpAffineInit and released by function SimdRelease.
[in]src- a pointer to pixels data of the original input image.
[out]dst- a pointer to pixels data of the filtered output image.

◆ WarpAffine()

void WarpAffine ( const View< A > &  src,
const float *  mat,
View< A > &  dst,
SimdWarpAffineFlags  flags = (SimdWarpAffineFlags)(SimdWarpAffineChannelByte | SimdWarpAffineInterpBilinear | SimdWarpAffineBorderConstant),
const uint8_t *  border = NULL 
)

Performs warp affine for current image.

Note
This function is a C++ wrapper for functions SimdWarpAffineInit and SimdWarpAffineRun.
Parameters
[in]src- an input image.
[in]mat- a pointer to 2x3 matrix with coefficients of affine warp.
[in,out]dst- an output image.
[in]flags- a flags of algorithm parameters. By default is equal to SimdWarpAffineChannelByte | SimdWarpAffineInterpBilinear | SimdWarpAffineBorderConstant.
[in]border- a pointer to to the array with color of border. The size of the array must be equal to channels. It parameter is actual for SimdWarpAffineBorderConstant flag. By default is equal to NULL.

◆ InvertAffineTransform()

bool InvertAffineTransform ( const float *  src,
float *  dst 
)

Performs inversion of warp affine transform matrix.

Note
This function is a C++ wrapper for functions SimdWarpAffineInit and SimdWarpAffineRun.
Parameters
[in]src- a pointer to input 2x3 matrix with coefficients of affine warp.
[out]dst- a pointer to output 2x3 matrix with coefficients of inverse affine warp.
Returns
false if can't inverse it.