# How can I extract trace points from an oscilloscope image?

I have the following oscilloscope image:

I would like to extract the points of the yellow curve together with the correct values. Do you know how I could do it?

Extracting the yellow curve from the background seems quite difficult to me.

• The information for "correct value" can not be derived from the image alone. You will need to know what the grid lines on the scope represent in physical units to scale from pixel coordinates to physical units. Commented Mar 8, 2018 at 14:14
• Dude this is an image from digital oscilloscope, use your hardware properly to get raw data. Commented Mar 8, 2018 at 17:14
• There's this answer which should help. Commented Mar 8, 2018 at 23:21
• ... and this answer. Plenty of tools to get the job done. Commented Mar 8, 2018 at 23:22
• @VsevolodA. Maybe the OP has no control on the oscillator. Commented Mar 9, 2018 at 0:14

Here I trim manually, but you could use Image[MorphologicalComponents[img] and detect the bounding box instead (actually, that's how I found 57 and 455).

img = Import["https://i.sstatic.net/NYfVj.png"]
pt1 = {12, 57};
pt2 = {600, 455};
imgCurve = ImageTrim[Image[MorphologicalComponents[img2]], {pt1, pt2}]
imgGrid = ImageTrim[Image[MorphologicalComponents[img]], {pt1, pt2}] - imgCurve


Then it's not difficult to get the points:

data1 = ImageData[Binarize@imgCurve];
points = Reverse /@ Position[data1, 1];
points[[All, 2]] = 520 - points[[All, 2]];
ListPlot@points


If you understand this, then you can extract the width and height of the grid, and scale the points accordingly.

• Thanks a lot ! This is very nice!! Commented Mar 10, 2018 at 7:59
• @anderstood, very nice example, by the way how can we set xmin, xmax, ymin, ymax for this benchmark in MMA? Commented Oct 31, 2019 at 11:26
• @ABCDEMMM Check PlotRange in ListPlot documentation (or ImageTrim depending on what you want). Commented Oct 31, 2019 at 12:18
• @anderstood what is the meaning for pt1 = {12, 57}; pt2 = {600, 455}; Commented Oct 31, 2019 at 15:33

If you are looking for an interactive solution sometimes it is easier and more flexible to use a specialized standalone program for digitizing graph images. Here is a web-based program that is free to use: https://automeris.io/WebPlotDigitizer/ The program is distributed under the GNU Affero General Public License Version 3.

To illustrate, I digitized your oscilloscope graph, with the following procedure:

1. Edit the image file to remove the crosshair mark at the center of your graph, because this will interfere with the digitizing process
2. Go to WebPlotDigitizer site and load the image file. You can also import an image URL if you do not need to clean it up.
3. After you Align the axes, put a Box around the graph area before extraction. For your graph I used Automatic Extraction using Distance=200, Averaging Window, delX=delY=1 Px
4. After you finish digitizing, go to View Data and download the data as a .CSV file.
5. Move the downloaded .CSV file to the correct directory for Mathematica to find it (use Directory[] to find your default folder)

Now you can import and use the data file in Mathematica, as follows:

Directory[]
data = Import["Default Dataset.csv", "CSV"];
ListPlot[data]


• Thank you very much ! This is a nice website and tool !! Commented Mar 10, 2018 at 8:00
• @Vixillator, automatically digitizing graph images is not possible? namely not click on each node .... Commented Oct 31, 2019 at 15:40
• If multiple graph images have the same x and y axis alignments, the same x and y axis origin (zero) position, the same x and y axis distance scales, and the same x and y axis increments per pixel (delX and delY), then once you have properly defined these digitizing parameters for the first graph image (as I outlined above) you can digitize all subsequent graph images automatically without redefining the parameters. Commented Nov 2, 2019 at 1:03
• WebPlotDigitizer is good but I have seen a lot of bugs in it. I personally preferred PlotDigitizer.com over WebPlotDigitizer. Commented Jan 15, 2021 at 8:14