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) > > > str(baboon) > 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 > ... > > class(baboon) > [1] "pixmapGrey" > > library(pixmap) > > plot(baboon) > > identify(baboon, n=1) > > ... and then R bombs! > > What to do? >
As Kenneth said, give identify() the expanded grid of points, but there is something wrong here: > library(pixmap) > example(pixmap) .... pixmap> plot(z[1:20, 10:40]) > identify(z, n=1) 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. > version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 1 minor 7.1 year 2003 month 06 day 16 language R Package: pixmap Version: 0.3-2 > Kjetil Halvorsen > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: [EMAIL PROTECTED] ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help