Specifications
Geometric Transforms
11-25
11
Discussion
The functions iplWarpPerspective() and iplWarpPerspectiveQ()
warp the source image by a perspective transformation according to the
following formulas:
x’ =(c
00
·x + c
01
·y + c
02
)/(c
20
·x + c
21
·y + c
22
)
y’ =(c
10
·x + c
11
·y + c
12
)/(c
20
·x + c
21
·y + c
22
)
where x and y denote the original pixel coordinates; x’ and y’ denote the
pixel coordinates in the transformed image.
The two functions differ in their third argument:
iplWarpPerspective()
uses a 3-by-3 input array of transform coefficients c
mn
=
coeff
[m][n],
whereas iplWarpPerspectiveQ() computes the coefficients internally
from the input array
quad
containing coordinates of the reference
quadrangle.
If
warpFlag
is IPL_R_TO_Q, the functions transform the rectangular ROI
of the source image into the reference quadrangle of the resultant image.
If
warpFlag
is IPL_Q_TO_R, the functions transform the source quadrangle
into the rectangular ROI of the resultant image.
The interpolation specified by
interpolate
is used for resampling the
input image.
To compute the perspective transform parameters, use these auxiliary
functions:
iplGetPerspectiveBound(), iplGetPerspectiveQuad()
and iplGetPerspectiveTransform(). They are described in the sections
that follow.