Re: [R] solving for a 2D transformation matrix

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat 03 Jul 2004 - 16:07:40 EST


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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Jul 03 16:11:10 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:40 EST