imagedata: Digitize a linear-scale plot that is shown in a graphics...

Description Usage Arguments Details Value Examples

Description

imagedata, the main function of the 'imagedata' package, digitizes points from images. As of now, the images must be in PNG format, and the axes must be linear. Also, at least on OS X machines, the plot device type must be quartz, since x11 does not properly buffer text in the console when combined with clicks in the plot window.

Usage

1
2
imagedata(image, xaxis, yaxis, rotated = FALSE, col = "red", pch = 20,
  cex = 1)

Arguments

image

name of image file (must be PNG)

xaxis

values along the x axis, typically at tick marks

yaxis

values along the y axis, typically at tick marks

rotated

a logical indicating whether the axes are rotated

col

colour of points, as for par

pch

type of points, as for par

cex

size of points, as for par

Details

If rotated is TRUE, then the first step is to display the image with a red diagonal line and red dotted horizontal and vertical lines, inviting the user to click above or below the diagonal line to alter the rotation angle. Any click that is to the left of the centre of the image will end this step, storing the inferred angle. The idea of this interactive method is to help in cases of flawed documents, e.g. those created with a photocopier.

Then the user is asked to click somewhere at the bottom-left of image, to set up an "UNDO" zone, and then the top-right, to set up a "STOP" zone. Normally these zones are placed outside the axis; they only have to be large enough to be easily clicked within.

Next, the user asked to click on the x axis, at values given by the xaxis argument. These values are normally at tick marks. The same is then done for the y axis.

Then it's time to digitize image data. If a mistake is made, click in the UNDO zone. To stop digitizing, click in the STOP zone. The results of imagedata are a list, of which the two most interesting components are x and y, the coordinates of the clicked points, translated to the coordinates of the plot (i.e. using the axis information).

Value

imagedata returns a list containing x and y values, which are the digitized points, X and Y, which are lists containing a and b values that hold the axis transformations, S, a list containing x and y defining the lower-left corner of the STOP zone, and U, a list containing the x and y defining the upper-right corner of the UNDO zone.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# Create a PNG file
x <- 1:10
y <- 1 + x + x %% 2
png("test.png")
par(mar=c(3, 3, 1, 1), mgp=c(2, 0.7, 0))
plot(x, y)
dev.off()

# Test with a non-rotated image (e.g. screen capture)
xy <- imagedata("test.png", c(2, 10), c(4, 10))

# Test with a rotated image (e.g. photocopy)
xy <- imagedata("testr.png", c(2, 10), c(4, 10), rotated=TRUE)

## End(Not run)

dankelley/imagedata documentation built on May 14, 2019, 4:09 p.m.