[R] Weird feature in rimage

Alberto Monteiro albmont at centroin.com.br
Mon Mar 10 12:59:31 CET 2008


I just noticed a weird feature in rimage. It seems that, when
reading an image, the line/colums are transposed.

See this reproducible example. The final image should be black - but (as 
expected) not an absolute black (mean(z) is 0.015, sd(z) is 0.055 but
max(z) is 1).

Alberto Monteiro

# reproducible example
#
# load image of a cat
#
library(rimage)
x <- read.jpeg(system.file("data", "cat.jpg", package="rimage")) 
#
# save the same image of the cat
# weird feature: dimensions are transposed (!)
#
jpeg("newcat.jpg", width=(dim(x)[2]), height=(dim(x)[1])) 
par(mar=rep(0, 4)) 
plot(x) 
dev.off() 
#
# load second image of the cat - should be similar but not equal
# (jpeg is a lossy format)
#
y <- read.jpeg("newcat.jpg")
#
# Construct the differences
#
z.mat <- abs(x - y)
z <- imagematrix(z.mat)
#
# Watch the differences
#
plot(z)
#
# Analyse the differences
#
mean(z)
sd(z)
max(z)



More information about the R-help mailing list