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.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI 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.
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
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.
PlotRange
in ListPlot
documentation (or ImageTrim
depending on what you want).
$\endgroup$
Oct 31, 2019 at 12:18
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:
Now you can import and use the data file in Mathematica, as follows:
Directory[]
data = Import["Default Dataset.csv", "CSV"];
ListPlot[data]