Translate an input image. More...

Functions

AFAPI array translate (const array &in, const float trans0, const float trans1, const dim_t odim0=0, const dim_t odim1=0, const interpType method=AF_INTERP_NEAREST)
 C++ Interface for translating an image. More...
 
AFAPI af_err af_translate (af_array *out, const af_array in, const float trans0, const float trans1, const dim_t odim0, const dim_t odim1, const af_interp_type method)
 C Interface for translate an image. More...
 

Detailed Description

Translate an input image.

Translating an image is moving it along 1st and 2nd dimensions by trans0 and trans1. Positive values of these will move the data towards negative x and negative y whereas negative values of these will move the positive right and positive down. See the example below for more.

To specify an output dimension, use the odim0 and odim1 for dim0 and dim1 respectively. The size of 2rd and 3rd dimension is same as input. If odim0 and odim1 and not defined, then the output dimensions are same as the input dimensions and the data out of bounds will be discarded.

All new values that do not map to a location of the input array are set to 0.

Translate is a special case of the af::transform function.

in [5 3 1 1]
0.0000 5.0000 10.0000
1.0000 6.0000 11.0000
2.0000 7.0000 12.0000
3.0000 8.0000 13.0000
4.0000 9.0000 14.0000
// Moves +1 row up and -1 column left (1 column right)
translate(in, 1, -1, 7, 5, AF_INTERP_NEAREST) [7 5 1 1]
0.0000 1.0000 6.0000 11.0000 0.0000
0.0000 2.0000 7.0000 12.0000 0.0000
0.0000 3.0000 8.0000 13.0000 0.0000
0.0000 4.0000 9.0000 14.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
// Moves -2 row up (2 rows down) and -1 column left (1 column right)
translate(in, -2, -1, 6, 4, AF_INTERP_BILINEAR) [6 4 1 1]
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 5.0000 10.0000
0.0000 1.0000 6.0000 11.0000
0.0000 2.0000 7.0000 12.0000
0.0000 3.0000 8.0000 13.0000

Function Documentation

AFAPI af_err af_translate ( af_array out,
const af_array  in,
const float  trans0,
const float  trans1,
const dim_t  odim0,
const dim_t  odim1,
const af_interp_type  method 
)

C Interface for translate an image.

Parameters
[out]outwill contain the translated image
[in]inis input image
[in]trans0is amount by which the first dimension is translated
[in]trans1is amount by which the second dimension is translated
[in]odim0is the first output dimension
[in]odim1is the second output dimension
[in]methodis the interpolation type (Nearest by default)
Returns
AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.
AFAPI array af::translate ( const array in,
const float  trans0,
const float  trans1,
const dim_t  odim0 = 0,
const dim_t  odim1 = 0,
const interpType  method = AF_INTERP_NEAREST 
)

C++ Interface for translating an image.

Parameters
[in]inis input image
[in]trans0is amount by which the first dimension is translated
[in]trans1is amount by which the second dimension is translated
[in]odim0is the first output dimension
[in]odim1is the second output dimension
[in]methodis the interpolation type (Nearest by default)
Returns
the translated image
Examples:
image_processing/image_editing.cpp.