[R] solving for a 2D transformation matrix
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Jul 3 08:07:40 CEST 2004
The best least-squares fit maps centroid to centroid. So find the mean of
the observed and target, and shift the observed to match the target. That
just leaves a rotation, and I would directly maximize the sum of squared
errors over that using optimize().
On 2 Jul 2004, Russell Senior wrote:
>
> We have recently digitized a set of points from some scanned
> engineering drawings (in the form of PDFs). The digitization resulted
> in x,y page coordinates for each point. The scans were not aligned
> perfectly so there is a small rotation, and furthermore each
> projection (e.g. the yz-plane) on the drawing has a different offset
> from the page origin to the projection origin. From the dimensions
> indicated on the drawing, I know the intended "world" coordinates of a
> subset of the points. I want to use this subset of points to compute
> a best-fit transformation matrix so that the remaining points can be
> converted to world coordinates.
>
> The transformation matrix is (I think) of the form:
>
> [ x' ] [ a11 a12 a13 ] [ x ]
> | y' | = | a21 a22 a23 | | y |
> [ w' ] [ a31 a32 a33 ] [ w ]
>
> where:
>
> x,y = page coordinates
> x',y' = world coordinates
>
> a13 = translation of x
> a23 = translation of y
>
> a11 = scale * cos(theta)
> a12 = sin(theta)
> a21 = -sin(theta)
> a22 = scale * cos(theta)
>
> a31 = 0
> a31 = 0
> a33 = 1
> w' = 1
> w = 1
>
> Can anyone give me a pointer on how to go about solving for the
> transformation matrix given a set of points, where x,y and x',y' are
> available? I sense the presence a solution lingering in the murky
> mists, (some kind of least squares?) but I am not sure what it is or
> how to go about it exactly.
>
> Thanks for your help!
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list