|
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... | |
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 array af::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 |