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

Rolf Turner r.turner at auckland.ac.nz
Sat Aug 11 01:31:07 CEST 2012


This should indeed be considered a bug, and actually it has been fixed,
in version 1.28-2.  But, sad to say, that version has not yet been put up
on CRAN.  We've been getting flack from TPTB for releasing new versions
of spatstat too frequently --- so we've cut back on the update rate.

If anyone wants the debugged version of affine.im(), let me know and I
will email you the appropriate *.R file.

Marcelino's workaround should suffice for the time being if you just
want to wait until 1.28-2 is released.

     cheers,

         Rolf Turner

On 11/08/12 06:43, marcelino.delacruz at upm.es wrote:
> 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



More information about the R-sig-Geo mailing list