[Rd] Problem/anomalous behavior with image() function (and ReadImages?)

Dominick Samperi djsamperi at earthlink.net
Tue Oct 20 23:59:18 CEST 2009


When an RGB photo is displayed using R's image() function with
the help of the pixmap (or rimage) package it is common to see
an anomalous white line running across the picture (either
horizontally or vertically). The line can
be removed by simply stretching the image frame a little in the
direction perpendicular to the anomalous line, or by maximizing the
image frame (tested under Fedora 10; Windows could not be
tested because ReadImages package does not load properly under
Windows/Vista, and rimage is not available for Windows).

It does not help to use x11(width=10,hight=10) before the call to
image() with the hope that the frame will already be
large enough: image() just draws a larger image with an
anomalous white line (which can be removed in the way just
described).

Here is code that produces an image with anomalous white lines
on under Fedora 10:

library(rimage)
x <- read.jpeg(system.file("data", "cat.jpg", package="rimage"))
plot(x) # calls plot.imagematix(), which in turn calls image()

Alternatively, you can copy cat.jpg from the rimage package to
the data directory of ReadImages and do this:
library(pixmap)
library(ReadImages)
x <- read.jpeg(system.file("data", "cat.jpg", package="ReadImages")
catpixmap <- pixmapRGB(x) # convert imagemap to pixmap
plot(catpixmap) # plot.pixmap is an S4 method that also calls image()

(This alternative method is provided because rimage has an
irrelevant dependency on an external library FFTW2 that
complicates the process of installing rimage. The use of
cat.jpg is not essential. The same problem appears with
most jpg photo images.)

Dominick



More information about the R-devel mailing list