Skip to content

spatstat - affine a window - enlarging (with same center)

4 messages · Marcelino de la Cruz, Rolf Turner, Mathieu Rajerison

#
Hi  Mathieu,

Maybe Adrian or Rolf would give a more informated answer, but in the mean
time,  my opinion is that you should compute the centroid of the affined
window and apply a "counter"-shift equivalent to the  shift that
experiments the affined window.

Here's my example with the letterR window (I don't have the
metropolitan France map at hand)

data (letterR)

ratio <- 2 # example "ratio"

letterRa <- affine(letterR, mat=matrix(c(ratio,0,0,ratio), ncol=2))

# centroids of the original and affined windows
cLR <- centroid.owin(letterR)
cLRa <- centroid.owin(letterRa)

# this is the "counter"-shift
LRshift <- c(cLR[[1]]-cLRa[[1]], cLR[[2]]-cLRa[[2]])

# shift the affined window
letterRas<-shift(letterRa, vec=LRshift)

# see the results
plot(letterRas)
plot(letterR, add=T)
points(centroid.owin(letterR))
points(centroid.owin(letterRas), cex=2)

HTH,

Marcelino




Con fecha 22/11/2011, "Mathieu Rajerison" <mathieu.rajerison at gmail.com>
escribi?:
#
Marcelino is clearly far cleverer than I, since I was at first unable
to figure out what the problem was that Mathieu was complaining
of.  As far as I can understand things, Marcelino's solution is correct.

I can suggest a slight simplification of the commands:

U <- shift(letterR,origin="centroid")
W <- affine(U,mat=2*diag(2),vec=unlist(centroid.owin(letterR)))

To check out that this appears as desired do:

plot(W,main="")
plot(letterR,add=TRUE,border="red")

     cheers,

             Rolf
On 23/11/11 07:27, marcelino.delacruz at upm.es wrote:
1 day later