I have the following oscilloscope image:

enter image description here

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.

  • 2
    $\begingroup$ 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. $\endgroup$
    – m_goldberg
    Mar 8, 2018 at 14:14
  • 3
    $\begingroup$ Dude this is an image from digital oscilloscope, use your hardware properly to get raw data. $\endgroup$ Mar 8, 2018 at 17:14
  • 1
    $\begingroup$ There's this answer which should help. $\endgroup$ Mar 8, 2018 at 23:21
  • 1
    $\begingroup$ ... and this answer. Plenty of tools to get the job done. $\endgroup$ Mar 8, 2018 at 23:22
  • 2
    $\begingroup$ @VsevolodA. Maybe the OP has no control on the oscillator. $\endgroup$
    – anderstood
    Mar 9, 2018 at 0:14

2 Answers 2


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.stack.imgur.com/NYfVj.png"]
pt1 = {12, 57};
pt2 = {600, 455};
imgCurve = ImageTrim[Image[MorphologicalComponents[img2]], {pt1, pt2}]
imgGrid = ImageTrim[Image[MorphologicalComponents[img]], {pt1, pt2}] - imgCurve

enter image description here

enter image description here

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]];

enter image description here

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

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

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

enter image description here

  • 1
    $\begingroup$ Thank you very much ! This is a nice website and tool !! $\endgroup$
    – james
    Mar 10, 2018 at 8:00
  • $\begingroup$ @Vixillator, automatically digitizing graph images is not possible? namely not click on each node .... $\endgroup$
    Oct 31, 2019 at 15:40
  • $\begingroup$ 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. $\endgroup$
    – Vixillator
    Nov 2, 2019 at 1:03
  • $\begingroup$ WebPlotDigitizer is good but I have seen a lot of bugs in it. I personally preferred PlotDigitizer.com over WebPlotDigitizer. $\endgroup$
    – Anonymous
    Jan 15, 2021 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.