<< resize Geometric transformations Histograms >>

scicv >> Geometric transformations > warpAffine

warpAffine

Applies an affine transformation to an image.

Syntax

img_out = warpAffine(img_in, M, size[, flags[, borderType[, borderValue]]])

Parameters

img_in

Input image (Mat).

M

Transformation matrix (2x3 double matrix).

size

Size of the output image (1x2 double matrix).

flags

Can be a combination of:

  • interpolation method flag (see resize).
  • optional flag CV_WARP_INVERSE_MAP to specify an inverse transformation.
borderType

Pixel extrapolation method (double) (default BORDER_DEFAULT).

borderValue

Border value (double matrix 1xn n=1..4).

img_out

Output image (Mat).

Description

warpAffine transforms the source image using the specified matrix MwarpAffines an image, either to the specified size size, or by using the scale factors scale_x and scale_y.

Examples

scicv_Init();

img = imread(getSampleImage("puffin.png"));

subplot(1,2,1);
matplot(img);

// Translation (20,20)
trans = [1 0 20; ..
        0 1 20];
img_translate = warpAffine(img, trans, size(img));

subplot(1,2,2);
matplot(img_translate);

delete_Mat(img);
delete_Mat(img_translate);

Report an issue
<< resize Geometric transformations Histograms >>