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 warp affine context. More... | |
| SIMD_API void | SimdWarpAffineRun (const void *context, const uint8_t *src, uint8_t *dst) |
| Performs warp affine transformation 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
| enum SimdWarpAffineFlags |
Describes bit flags used by SimdWarpAffineInit.
Values are grouped into independent bit fields for channel type, interpolation method and border handling. Combine one value from each field with bitwise OR. Current implementations support 8-bit channels, nearest or bilinear interpolation, and constant or transparent border handling.
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 warp affine context.
The input matrix describes forward affine transformation from source coordinates to destination coordinates:
dstX = srcX*mat[0] + srcY*mat[1] + mat[2]; dstY = srcX*mat[3] + srcY*mat[4] + mat[5];
The context stores inverse matrix and, during SimdWarpAffineRun, samples source image for every destination pixel. Supported data type is 8-bit unsigned channels, supported channel count is 1..4, and supported interpolation methods are nearest and bilinear. With SimdWarpAffineBorderConstant, pixels outside the source image are filled by border color (zero color when border is NULL). With SimdWarpAffineBorderTransparent, destination pixels outside transformed source area are left unchanged.
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 forward affine transformation. [in] flags - flags of algorithm parameters (channel type, interpolation method and border method). [in] border - a pointer to the array with color of border. The size of the array must be equal to channels. This 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 transformation for current image.
The function uses parameters and precomputed data from the context created by SimdWarpAffineInit. If transparent border mode is used, destination image has to contain the background values before calling this function.
- 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 transformed 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 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.