[R-sig-Geo] spatstat::affine.im

marcelino.delacruz at upm.es marcelino.delacruz at upm.es
Fri Aug 10 20:43:57 CEST 2012


Hi Jose Manuel,

I don't think it is exactly a bug. Just try indicating the dimensions of
the resulting image:


> vec <- rnorm(1200)
> mat <- matrix(vec, nrow=30, ncol=40)
> whitenoise <- im(mat)
> whitenoise2 <- affine(whitenoise, mat=diag(c(2,3)),dimyx=c(30,40))
> whitenoise2
real-valued pixel image
30 x 40 pixel array (ny, nx)
enclosing rectangle: [1, 81] x [1.5, 91.5] units

Cheers,

Marcelino



Con fecha 10/8/2012, "JOSE MANUEL BLANCO MORENO" <jmblanco at ub.edu>
escribió:

>Regarding my previous query, the problem is in fact in line 22-23 of function affine.im, when calling affinexy; when calling affine.im for a rectangular image but applying a non-diagonal matrix, there is no problem, because affinexy is not executed.
>
>
>
>This example does not work (as  before):
>
>
>
>vec <- rnorm(1200)
>mat <- matrix(vec, nrow=30, ncol=40)
>whitenoise <- im(mat)
>whitenoise2 <- affine(whitenoise, mat=diag(c(2,3)))
>
>
>
>But this one does:
>
>
>
>vec <- rnorm(1200)
>mat <- matrix(vec, nrow=30, ncol=40)
>whitenoise <- im(mat)
>whitenoise2 <- affine(whitenoise, mat=matrix(c(1,8,8,1), ncol=2))
>
>
>
>Looks like a bug?
>
>---------------------------------------
>José M. Blanco-Moreno
>Dept. de Biologia Vegetal (Botànica)
>Facultat de Biologia
>Universitat de Barcelona
>Av. Diagonal 643
>08028 Barcelona
>SPAIN
>---------------------------------------
>phone: (+34) 934 039 863
>fax: (+34) 934 112 842
>---------------------------------------
>
>________________________________
>De: JOSE MANUEL BLANCO MORENO
>Enviat el: divendres, 10 / agost / 2012 15:13
>Per a: r-sig-geo at r-project.org
>Tema: spatstat::affine.im
>
>
>Dear users & experts,
>
>
>
>Does anyone know if affine transformation of images (function affine.im in spatstat) should work for non-square images? I thought it should, but I have tried:
>
>
>
>vec <- rnorm(1200)
>mat <- matrix(vec, nrow=30, ncol=40)
>whitenoise <- im(mat)
>whitenoise2 <- affine(whitenoise, mat=diag(c(2,3)))
>
>
>
>But I get:
>
>
>
>Error in im(v, xcol = xcol, yrow = yrow, xrange = newbox$xrange, yrange = newbox$yrange,  :
>  Length of yrow does not match nrow(mat)
>In addition: Warning message:
>In rbind(X$x, X$y) :
>  number of columns of result is not a multiple of vector length (arg 2)
>
>
>
>However if I modify the example allowing for a square image it works perfectly:
>
>
>
>vec <- rnorm(900)
>mat <- matrix(vec, nrow=30, ncol=30)
>whitenoise <- im(mat)
>whitenoise2 <- affine(whitenoise, mat=diag(c(2,3)))
>
>And the only difference that I can spot between these matrices/images is the shape of the image itself.
>
>
>
>Affine should work for non-square images, isn't it? Or I am wrong? Is there any way to circumvent this problem?
>
>
>
>These are version details:
>
>R version 2.15.1 (2012-06-22)
>Platform: i386-pc-mingw32/i386 (32-bit)
>
>locale:
>[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
>[4] LC_NUMERIC=C                           LC_TIME=English_United States1252
>
>attached base packages:
>[1] stats     graphics  grDevices utils     datasets  methods   base
>
>other attached packages:
>[1] spatstat_1.28-1 deldir_0.0-19   mgcv_1.7-18
>
>loaded via a namespace (and not attached):
>[1] grid_2.15.1    lattice_0.20-6 Matrix_1.0-6   nlme_3.1-104   tools_2.15.1
>
>
>
>---------------------------------------
>José M. Blanco-Moreno
>Dept. de Biologia Vegetal (Botànica)
>Facultat de Biologia
>Universitat de Barcelona
>Av. Diagonal 643
>08028 Barcelona
>SPAIN
>---------------------------------------
>phone: (+34) 934 039 863
>fax: (+34) 934 112 842
>---------------------------------------
>
>
>Aquest correu electrònic i els annexos poden contenir informació confidencial o protegida legalment i està adreçat exclusivament a la persona o entitat destinatària. Si no sou el destinatari final o la persona encarregada de rebre'l, no esteu autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si heu rebut aquest correu electrònic per error, us preguem que n'informeu al remitent i que elimineu del sistema el missatge i el material annex que pugui contenir. Gràcies per la vostra col·laboració.
>
>Este correo electrónico y sus anexos pueden contener información confidencial o legalmente protegida y está exclusivamente dirigido a la persona o entidad destinataria. Si usted no es el destinatario final o la persona encargada de recibirlo, no está autorizado a leerlo, retenerlo, modificarlo, distribuirlo, copiarlo ni a revelar su contenido. Si ha recibido este mensaje electrónico por error, le rogamos que informe al remitente y elimine del sistema el mensaje y el material anexo que pueda contener. Gracias por su colaboración.
>
>This email message and any documents attached to it may contain confidential or legally protected material and are intended solely for the use of the individual or organization to whom they are addressed. We remind you that if you are not the intended recipient of this email message or the person responsible for processing it, then you are not authorized to read, save, modify, send, copy or disclose any of its contents. If you have received this email message by mistake, we kindly ask you to inform the sender of this and to eliminate both the message and any attachments it carries from your account. Thank you for your collaboration.
>
>	[[alternative HTML version deleted]]
>



More information about the R-sig-Geo mailing list