[R] overlay two pixmap
Christoph Lehmann
christoph.lehmann at gmx.ch
Tue Sep 30 14:09:35 CEST 2003
when I try to overlay a completely transparent pixmap on another pixmap,
I get an error.
For reproduction: just the transparent pixmap itself gives an error:
tmp <- array(0,c(x.dim,y.dim))
tmp <- pixmapIndexed(tmp[,])
for (x in 1:x.dim) {
for (y in 1:y.dim) {
tmp at index[x,y] <- NA
} }
plot(tmp)
---- Error:
Error in image.default(x = X, y = Y, z = t(x at index[nrow(x at index):1, ]),
:
invalid z limits
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
what happened here?
many thanks
christoph
On Fri, 2003-09-26 at 12:44, Roger Bivand wrote:
> Christoph Lehmann wrote:
>
> > I need to overlay two pixmaps (library (pixmap)). One, a pixmapGrey, is
> > the basis, and on this I need to overlay a pixmapIndexed, BUT: the
> > pixmapIndexed has set only some of its "pixels" to an indexed color,
> > many of its pixels should not cover the basis pixmapGrey pixel, means,
> > for this "in pixmapIndexed not defined pixels" it should be transparent.
>
> > What would you recommend me to do? Should I go for another solution than
> > pixmap?
>
> Determine which of the indexed colours in the pixmapIndexed object are to
> be transparent, and change them to NA - you access them in say:
>
> library(pixmap)
> x <- read.pnm(system.file("pictures/logo.ppm", package = "pixmap")[1])
> x
> plot(x)
> xx <- as(x, "pixmapIndexed")
> xx
> plot(xx)
> example(pixmap)
> z <- pixmapRGB(c(z1, z2, z3), 100, 100, bbox = c(0, 0, 100, 100))
> plot(z)
> xx at col[1:20]
> xx at col[1] <- NA
> plot(xx, add=T)
>
> Here xx at col[1] was "white" aka "#FFFFFF", you could use col2rgb() to help
> set thresholds. Admittedly, this is messy if you don't know your
> threshold.
>
> Roger
--
Christoph Lehmann <christoph.lehmann at gmx.ch>
More information about the R-help
mailing list