How to digitise a scanned image

For instance, suppose we had a graph from a technical paper, and we wanted to extract numerical data from the graph lines.  One way would be to measure the points by hand and calculate the numbers by scaling from the axes, but that would be inaccurate, error prone and tedious.  Another way would be to scan the graph and paste it into a program that will return the screen coordinates of selected points, and scale the screen coordinates to graph coordinates.  I have written a VBA program to make this procedure quick and easy: DigitGraph.xls (including full open source code).

The procedure is:

  • Paste the scanned image, and drag to a convenient size.
  • Select the rectangle named “Axes”:
  • Drag the rectangle so the bottom left corner is at the origin.
  • Stretch the top right corner so that the left and bottom edges extend to points with known ordinates.
  • Draw over the lines or shapes to be digitised, using a single freeform shape for each line.
  • Give the drawn shapes any unique name.
  • Enter the Digitgraph function as shown below, where XLen and YLen are the true length of the X and Y axes.
  • If the origin has non-zero coordinates enter Xorigin and Yorigin.
  • Enter the function as an array function: Select the output range, press F2, then press Ctrl-Shift-Enter

The function arguments are: =DigitGraph(Shape Name, XLen, YLen, Xorigin, Yorigin)

The function will return a list of coordinates of the traced lines, to the scale of the X and Y axes.

Example output is shown in the screen shot below, using a scanned graph of a beam deflection experiment.  The DigitGraph function results are on the right, showing the number of points in the traced polyline, followed by XY coordinates, to graph scale, for each point.

Traced graph and DigitGraph output; click for full size view

This entry was posted in Drawing, Excel, UDFs, VBA and tagged , , , . Bookmark the permalink.

19 Responses to How to digitise a scanned image

  1. Ross says:

    Nicely done!!! I’ve often thought about doign this, although I was going to actually capture the x/y with a mouse click, nice job Doug
    Ross

    Like

  2. This is very nice and handy too.
    It only works with linear axes, though.

    I used to mess with physics graphs in my past, and you get lots of graphs with logarithmic axes (sometimes just the X, sometimes just Y, and sometimes both)

    This tool with logarithmic axes support would have been a killer back then!

    Don’t get me started on trying to do this with Matlab…
    Good job!

    Like

  3. Pingback: Digitising logarithmic scales « Newton Excel Bach, not (just) an Excel Blog

  4. Pingback: Excel as a digitizer « Excel Tips Monster

  5. Nick Holford says:

    This looks very flexible but I need an explanation of how to give a name to a shape. How did you give the name ‘measured’ to the red line?

    “Give the drawn shapes any unique name (the drawn line is the red line named “measured” in the example below.)”

    Nick

    Like

  6. dougaj4 says:

    Nick – select the shape by clicking on a boundary, then type the name in the name box in the top left hand corner. When the shape is selected the name box will display the default name (something like rectangle 3). You can just type over it.

    You can do the same thing to name a range by the way.

    Like

  7. george lungu says:

    Doug,
    Great work, thank you. I still get “artifact” point (the first one with a very large x coordinate).
    George

    Like

  8. Rudy Wilhelm says:

    I have been looking for something like the DigitGraph Function for a long time. Thank you so much for a) figuring out this elegant solution, b) for even sharing it, c) even for free. It’s just so beautiful. Thank you so much. You are my HERO!

    Like

  9. Pingback: The Dome of Santa Maria del Fiore – Dimensions | Newton Excel Bach, not (just) an Excel Blog

  10. Pingback: Daily Download 10: Excel Digitiser | Newton Excel Bach, not (just) an Excel Blog

  11. cmata says:

    Doug, awesome tool! As a geotechnical engineer I have to plot lots of data into graphs from several authors, which your function made a lot easier. Thank you so much for sharing this tool, keep up the good work!

    Like

  12. Gabriel says:

    Thanks for this fantastic tool. It is possible to digitize singular points instead of lines or curves?

    Like

  13. Gabriel says:

    I know the reply to my own question. You can put the nodes in the points you want to digitalize.

    Thanks for the fantastic tool!

    Like

  14. Pingback: DigitGraph Spreadsheet and WebPlot Digitiser | Newton Excel Bach, not (just) an Excel Blog

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.