[R] geometric transformation

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Tue Jan 22 10:39:27 CET 2008


Javier,

You can use two lm-models for that. One for each coordinate. Then use
predict() to calculate the coordinates of the other points. And by the
way: four points is not very much data to calculate a transformation. I
mlight work if the image is not very much distorted and you have precise
measurement of the reference points coordinates.

corners.px <- matrix(c(212.5, 275.5, 562.5, 275.5, 212.5, 625.5, 562.5,
625.5), ncol = 2, byrow = TRUE)
corners.r <- matrix(c(139463, 8386, 139579, -1294, 131921, 8180, 132002,
-1256), ncol = 2, byrow = TRUE)
dataset <- data.frame(cbind(corners.px, corners.r))
colnames(dataset) <- c("X", "Y", "U", "V")
lm(U ~ X + Y, data = dataset)
lm(V ~ X + Y, data = dataset) 

HTH,

Thierry

PS R-sig-GEO would be more suitable for this kind of question.

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
Namens jgarcia op ija.csic.es
Verzonden: dinsdag 22 januari 2008 9:56
Aan: r-help op r-project.org
Onderwerp: [R] geometric transformation

Hi everyone,

I've got a set of thousands points (2D) located on a pixel image, and I
know that four points in this pixels image correspond to four points in
a
real space on which I need to locate the mapping of all the thousand
source points from the pixel set.
For this I've got four reference points (corners.px), and the
corresponding four destination points (corners.r):

> corners.px
      [,1]  [,2]
[1,] 212.5 275.5
[2,] 562.5 275.5
[3,] 212.5 625.5
[4,] 562.5 625.5

> corners.r
       [,1]  [,2]
[1,] 139463  8386
[2,] 139579 -1294
[3,] 131921  8180
[4,] 132002 -1256

I think I must find a transformation matrix and apply this
transformation
matrix to all the set in the pixel space, but cannot find the way to
contruct this transformation matrix.
I guess this is not a question just pertaining to R, but perhaps you can
help me with this.

Thank you and best regards!

Javier
-----

______________________________________________
R-help op r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list