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... | |
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.
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.
[out] | out | will contain the transformed image |
[in] | in | is input image |
[in] | transform | is transformation matrix |
[in] | odim0 | is the first output dimension |
[in] | odim1 | is the second output dimension |
[in] | method | is the interpolation type (Nearest by default) |
[in] | inverse | if true applies inverse transform, if false applies forward transoform |
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.
[out] | out | will contain the transformed image |
[in] | in | is input image |
[in] | transform | is transformation matrix |
[in] | odim0 | is the first output dimension |
[in] | odim1 | is the second output dimension |
[in] | method | is the interpolation type (Nearest by default) |
[in] | inverse | if true applies inverse transform, if false applies forward transoform |
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 af_array
that has not been initialized to out
will cause undefined behavior. 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.
[in] | in | is input image |
[in] | transform | is transformation matrix |
[in] | odim0 | is the first output dimension |
[in] | odim1 | is the second output dimension |
[in] | method | is the interpolation type (Nearest by default) |
[in] | inverse | if true applies inverse transform, if false applies forward transoform |