A high-performance general-purpose compute library

Transform an input image. More...

Functions

AFAPI array transform (const array &in, const array &transform, const dim_t odim0=0, const dim_t odim1=0, const interpType method=AF_INTERP_NEAREST, const bool inverse=true)
 C++ Interface for transforming an image. More...
 
AFAPI af_err af_transform (af_array *out, const af_array in, const af_array transform, const dim_t odim0, const dim_t odim1, const af_interp_type method, const bool inverse)
 C Interface for transforming an image. More...
 
AFAPI af_err af_transform_v2 (af_array *out, const af_array in, const af_array transform, const dim_t odim0, const dim_t odim1, const af_interp_type method, const bool inverse)
 C Interface for the version of af_transform that accepts a preallocated output array. More...
 

Detailed Description

Transform an input image.

The transform function uses an affine or perspective transform matrix to tranform an input image into a new one.

If matrix tf is is a 3x2 matrix, an affine transformation will be performed. The matrix operation is applied to each location (x, y) that is then transformed to (x', y') of the new array. Hence the transformation is an element-wise operation.

The operation is as below:
tf = [r00 r10
r01 r11
t0 t1]

x' = x * r00 + y * r01 + t0;
y' = x * r10 + y * r11 + t1;

If matrix tf is is a 3x3 matrix, a perspective transformation will be performed.

The operation is as below:
tf = [r00 r10 r20
r01 r11 r21
t0 t1 t2]

x' = (x * r00 + y * r01 + t0) / (x * r20 + y * r21 + t2);
y' = (x * r10 + y * r11 + t1) / (x * r20 + y * r21 + t2);

The transformation matrix tf should always be of type f32.

Interpolation types of AF_INTERP_NEAREST, AF_INTERP_BILINEAR and AF_INTERP_LOWER are allowed.

Affine transforms can be used for various purposes. af::translate, af::scale and af::skew are specializations of the transform function.

Function Documentation

◆ af_transform()

AFAPI af_err af_transform ( af_array out,
const af_array  in,
const af_array  transform,
const dim_t  odim0,
const dim_t  odim1,
const af_interp_type  method,
const bool  inverse 
)

C Interface for transforming an image.

Parameters
[out]outwill contain the transformed image
[in]inis input image
[in]transformis transformation matrix
[in]odim0is the first output dimension
[in]odim1is the second output dimension
[in]methodis the interpolation type (Nearest by default)
[in]inverseif true applies inverse transform, if false applies forward transoform
Returns
AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.

◆ af_transform_v2()

AFAPI af_err af_transform_v2 ( af_array out,
const af_array  in,
const af_array  transform,
const dim_t  odim0,
const dim_t  odim1,
const af_interp_type  method,
const bool  inverse 
)

C Interface for the version of af_transform that accepts a preallocated output array.

Parameters
[out]outwill contain the transformed image
[in]inis input image
[in]transformis transformation matrix
[in]odim0is the first output dimension
[in]odim1is the second output dimension
[in]methodis the interpolation type (Nearest by default)
[in]inverseif true applies inverse transform, if false applies forward transoform
Returns
AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.
Note
out can either be a null or existing af_array object. If it is a sub-array of an existing af_array, only the corresponding portion of the af_array will be overwritten
Passing an af_array that has not been initialized to out will cause undefined behavior.

◆ transform()

AFAPI array transform ( const array in,
const array transform,
const dim_t  odim0 = 0,
const dim_t  odim1 = 0,
const interpType  method = AF_INTERP_NEAREST,
const bool  inverse = true 
)

C++ Interface for transforming an image.

Parameters
[in]inis input image
[in]transformis transformation matrix
[in]odim0is the first output dimension
[in]odim1is the second output dimension
[in]methodis the interpolation type (Nearest by default)
[in]inverseif true applies inverse transform, if false applies forward transoform
Returns
the transformed image