Re: [S] grey shades in `image'

Prof Brian D Ripley (ripley@stats.ox.ac.uk)
Fri, 24 Jul 1998 07:32:43 +0100 (BST)


On Thu, 23 Jul 1998 andrey@utstat.toronto.edu wrote:

> I am using Version 3.4 Release 1 for Silicon Graphics Iris, IRIX 5.3
> of S-Plus on a UNIX system, and an HP Laserjet 4si printer.
>
> I need to produce grey scale images using the `image' command in S-Plus.
>
> When I do this I seem to get 8 shades of grey, although I do not
> believe this to be a limitation of the printer. How can I produce
> an image of my data matrix with 128 shades of grey?

I doubt that your printer can do 128. Of course, it cannot do grey at all,
rather it uses half-toning. The actual number of levels produced depends on
the `screen' setting in the printer. At their default settings 300dpi
printers can do around 15 different half tones, and 600dpi ones (a 4Si is
600dpi, I believe) about twice that. You can get more by changing the
screen with setscreen. And even if you had 128 shades, your eye would not
be able to distinguish them; 64 suffices to give an impression of
continuous tones if the pixels are small enough.

However, I am completely puzzled as to how you get 8. How are you making
the plot? By a postscript device? By copying the screen?

Here's an experiment in 3.4:

> library(MASS)
> postscript("junk.ps", width=8, height=6, pointsize=9)
> topo.loess <- loess(z ~ x * y, topo, degree=2, span = 0.25)
> topo.mar <- list(x = seq(0, 6.5, 0.1), y=seq(0, 6.5, 0.1))
> topo.lo <- predict(topo.loess, expand.grid(topo.mar))
> par(pty="s") # square plot
> image(topo.mar$x, topo.mar$y, topo.lo, xlab="", ylab="")

and I get 16 colours. And I believe 16 colours is a fundamental
limitation of S's image. If you want more, use levelplot in Trellis:

trellis.device(postscript, file="junk.ps", width=8, height=6, pointsize=9)
topo.plt <- expand.grid(topo.mar)
topo.plt$pred <- as.vector(predict(topo.loess, topo.plt))
levelplot(pred ~ x * y, topo.plt, aspect=1, cuts=64)

The maximum number of levels you can get that way is 100, but that
should suffice. (You can build your own Trellis device if you need more,
but you don't for greyscale plots.)

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

----------------------------------------------------------------------- This message was distributed by s-news@wubios.wustl.edu. To unsubscribe send e-mail to s-news-request@wubios.wustl.edu with the BODY of the message: unsubscribe s-news