Skip to content

Instantly share code, notes, and snippets.

@krlmlr
Created October 8, 2014 22:23
Show Gist options
  • Select an option

  • Save krlmlr/309b88b4be21a9180c6f to your computer and use it in GitHub Desktop.

Select an option

Save krlmlr/309b88b4be21a9180c6f to your computer and use it in GitHub Desktop.
m1 <- png::readPNG("~/Downloads/m1.png")
m2 <- png::readPNG("~/Downloads/m2.png")
m1r <- m1[,,1]
m2r <- m2[,,1]
m1r1 <- m1r[,1]
m2r1 <- m2r[,1]
sim <- llply(
rev(seq_len(dim(m1)[2])),
function(x) {
m2x <- m2[,seq_len(x),]
m1x <- m1[,seq(to = dim(m1)[2], length.out = x),]
dmx <- m2x - m1x
dmx <- dmx * dmx
mean(dmx)
},
.progress = "text"
)
sim2 <- llply(
rev(seq_len(dim(m1)[2])),
function(x) {
m2x <- m2[c(1, 17,155),seq_len(x),]
m1x <- m1[c(1, 17,155),seq(to = dim(m1)[2], length.out = x),]
dmx <- m2x - m1x
dmx <- dmx * dmx
mean(dmx)
},
.progress = "text"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment