On Tue, 2 Sep 2003, kjetil brinchmann halvorsen wrote:
Hola!
I will want to identify pixels in an image with the mouse, for
so getting the image data from the matrix(es), for use in subsequent
discriminant analysis. But the following bombs R:
(windows XP, rw1071)
list()
- attr(*, "size")= int [1:2] 512 512
- attr(*, "cellres")= num [1:2] 1 1
- attr(*, "bbox")= num [1:4] 0 0 512 512
- attr(*, "channels")= chr "grey"
- attr(*, "bbcent")= logi FALSE
- attr(*, "class")= chr "pixmapGrey"
- attr(*, "grey")= num [1:512, 1:512] 0.537 0.510 0.345 0.259 0.322
...
library(pixmap)
plot(baboon)
identify(baboon, n=1)
... and then R bombs!
What to do?
....
pixmap> plot(z[1:20, 10:40])
Program received signal SIGSEGV, Segmentation fault.
do_set (call=0x869ce7c, op=0x8299648, args=0x869ce98, rho=0x8f2496c)
at eval.c:1308
1308 switch (NAMED(s)) {
The identify.default() function is passing the pixmap object through to
xy.coords(), which returns two empty x and y vectors, which are checked
for length in the R code - xy.coords() treats the pixmap object as a list,
does:
} else if (is.list(x)) {
xlab <- paste(ylab, "$x", sep = "")
ylab <- paste(ylab, "$y", sep = "")
y <- x[["y"]]
x <- x[["x"]]
} else {
and y and x are the same length, so returns to identify.default() with
nothing, which is passed on to the .Internal() undetected. Two
possibilities - an identify.pixmap() in pixmap, or a test for the
(package, S4) pixmap class in xy.coords. But as it stands, it's a quick
way to exit the program. xy.coords() seems to be trusting the user to have
a list with x and y components, and here it has neither. The list is
indeed empty, being an S4 class - it just has attributes.