Re: [R] Using locator() to digitise

From: M.Kondrin <mkondrin_at_hppi.troitsk.ru>
Date: Mon 21 Mar 2005 - 15:38:08 EST

(Ted Harding) wrote:

>Hi Folks,
>
>I'm contemplating using locator() to digitise external
>graphics. To set context, I would be using X11 display
>on Linux.
>
>
Hi, Ted!
Beside searching for specialized packages, I would suggest you to try my package RImgViewer which uses Gtk2 library to import and display images in R-session. It is not available on CRAN because it depends on two other packages (RGtk2 and GdkDrawing) which conflict with Duncan T. Lang RGtk package. All of them can be downloaded from my homepage (www.hppi.troitsk.ru/Kondrin/r_img_viewer_html.html , www.hppi.troitsk.ru/Kondrin ). It is mainly untested (except by me) and I hope you would send me bug-reports if you find the package worth it.
For your purposes this package can be used in this way. You can use the image viewer to import and display your scanned image (because RImgViewer use specialized widget for image displaying it is quite fast). Then you can convert displayed graphics into R-array and with markers provided by RImgViewer select region of interest. In your case it could be selecting axii' directions. From coordinates of this markers you can construct rotation matrix and calculate true coordinates of each point from its array indexes. The coordinates of drawn curves are the coordinates of points with values 0 (i.e.black). I usually digitize the whole picture and then use R to delete points which I do not need and to smooth the rest.
Hope this helps.

>To pre-empt the obvious comment: I've found on the R site
>the suggestion to use the 'pixmap' package. I've tried
>this, and it works; but it involves building a big R
>object (the internal pixmap representation), and this
>chokes my somewhat puny laptop (e.g. it can take about
>1 minute to draw the graphic inside a plot area using
>addlogo(), with mucho swappo, and subsequently working
>knee-deep in treacle). The following idea would be a lot
>slicker.
>
>For examples: I have something like
>
>a) A scatterplot of data printed in a journal (but the
> data values are not available;
>
>b) A contour map (on paper) of a region.
>
>So, I can scan the document, and obtain a file in some
>graphics format (jpeg, pbm or png, say).
>
>Now: an idea which I find attractive is to be able to
>overlay an R plot with axes onto a display of the graphics
>file (produced as an X window by any suitable program such
>as 'xv' or 'display') so that (if the overlay were possible)
>clicking on the points of the graphic would in fact be
>clicking on the R plot and, via locator(), generate the
>R-plot coordinates of the mouse clicks which would correspond
>to the selected points on the graphic.
>
>Provided the coordinate system of the R plot were properly
>related to the graphic, the results would be a digitisation
>of the selected points on the graphic.
>
>What seems to be needed for this idea to work is that
>the R-plot should be displayed in an X11() device whose
>background was completely transparent, so that when
>moved over the (independently generated) display of the
>graphic the latter would be visible (but locator() would
>still be working on the R-plot itself). Window resizing
>could look after the correspondence between graphic coordinates
>and R-plot coordinates.
>
>The R plot itself could be empty (apart from coordinate axes)
>or could contain "helper" elements such as grid lines, circles
>(e.g. I want to digitise graphics points within a certain circle),
>etc. "Helper" elements could be added to the R-plot by subsequent
>'lines' or 'points' commands (e.g. I identify two points on
>the graphic, R-plot the line joining them, and then pick off
>graphic-points which lie on the R-line).
>
>So this question is really about producing a "bare" R plot
>on, as it were, a virtual acrylic transparency. It's certainly
>possible to do such a thing in X: e.g. the cute "xteddy" is
>in fact a picture of a bear on a completely transparent
>rectangular background, though you'd never know by looking!
>
>Any comments?
>
>With thanks, and best wishes to all,
>Ted.
>
>
>--------------------------------------------------------------------
>E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk>
>Fax-to-email: +44 (0)870 094 0861
>Date: 20-Mar-05 Time: 16:09:11
>------------------------------ XFMail ------------------------------
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Mar 21 19:45:20 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:51 EST