Community
cancel
Showing results for
Did you mean:
Beginner
44 Views

## WarpAffine

I am looking for some help to do the following: I have a 2D affine
transform obtained from an external source, and I am trying to use
this to resample an Image using WarpAffine. The transformation parameters
were calculated with reference to a center different from the origin. Since
WarpAffine has no parameter to specify thre center of the transform, I wanted
to know what sequence of steps I should pass my coeff[2][3] through, to ensure
that the transformation applied to the image is around the same center with
reference to which it was derived.

Thanks,
Sid.
3 Replies
Beginner
44 Views
Hi again,
I though a bit more about the problem, and I figured out
that I will have to recenter the coordinates, i.e X-C, prior to
applying the resampling on the grid. To restate,
If the usual approach for resampling is X' = AX, where A is the
transform and X is the image grid (giving f(X') actually), how do
I go about implementing X' = A(X-C) using available ip primitives,
where C is the center of the transform.
Thanks again,
Sid.
New Contributor I
44 Views
Hi Sid,

Let affine transform is
xD = c00*xS + c01*yS + c02
yD = c10*xS + c11*yS + c12

The coordinates of centers are (xScenter, yScenter) and (xDcenter, yDcenter).
So we should use:
xD = c00*(xS-xScenter) + c01*(yS-yScenter) + xDcenter
yD = c10*(xS-xScenter) + c11*(yS-yScenter) + yDcenter

Then the desired coefficients are
02 = xDcenter - c00*xScenter - c01*yScenter
12 = yDcenter - c10*xScenter - c11*yScenter

Thanks,
Beg
Beginner
44 Views
Hi Beg,