converting and shifting photo from osciloscope

5 visualizzazioni (ultimi 30 giorni)
fima v
fima v il 7 Ott 2024
Risposto: DGM il 9 Ott 2024
Hello, I have an osciloscope photo attached.As you can see I have two signals going from -1ms to 1ms.
Is there a way In Matlab I can extract the data from these plots into CSV format so the X axes will be will be 0 to 2ms?
Thanks.
  2 Commenti
Rik
Rik il 7 Ott 2024
Do you only have the image, or do you have the underlying data? Because extracting the data from the image (in high enough resolution) might not be possible.
fima v
fima v il 7 Ott 2024
I dont need high resolusion just the general contour of each plot.
Thanks.

Accedi per commentare.

Risposte (2)

Abhinav Aravindan
Abhinav Aravindan il 7 Ott 2024
To extract the approximate data points from the image, you may try utilizing the GUI program from the following File Exchange Submission.
Here are the steps you can follow to extract the data from the image of the oscilloscope.
  1. Load the image file.
  2. Calibrate axes dimensions by selecting the max/min X and Y data points and entering the corresponding value.
  3. Grab points by clicking on points along the line.
  4. Export the points into a MAT file.
Please find the output of the above steps for the “Green” curve in your image.
The exported points can be converted to CSV format as follows.
load('pulseData.mat')
writematrix(pulseData,"DSOdata.csv")
This data can be used to modify the X-axis as per your requirements.
Further you may refer to the below links wherein similar queries have been answered
I hope this helps!

DGM
DGM il 9 Ott 2024
Again, this would normally be my recommendation:
If the curves are all non-overlapping and equivalently-spaced saturated colors, you can get a jagged approximation instead:
% the image
inpict = imread('pulse.png');
% channel scaling and offsets [chan1 chan2 ... ]
vdiv = [5 5];
tdiv = [200E-3 200E-3];
voffset = [-1.960 -0.001];
toffset = [0 0];
% dominant hue for each trace
tracehue = [0.3 0.91];
% box extents in data divisions
xdivs = [-5 5];
ydivs = [-4 4];
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% prepare image
inpict = imcrop(inpict,[84.51 109.51 898.98 494.98]);
% find the colored lines
numtraces = numel(vdiv);
hsvpict = rgb2hsv(inpict);
hlim = mod(tracehue.' + [-0.1 0.1],1); % one row for each trace
slim = 0.95;
llim = 0.95;
tracemask = false([size(inpict,1:2) numtraces]);
slmask = (hsvpict(:,:,2)>=slim) & (hsvpict(:,:,3)>=llim);
for c = 1:numtraces
if hlim(c,1) > hlim(c,2)
mask = (hsvpict(:,:,1)>=hlim(c,1) | hsvpict(:,:,1)<=hlim(c,2));
else
mask = (hsvpict(:,:,1)>=hlim(c,1) & hsvpict(:,:,1)<=hlim(c,2));
end
mask = mask & slmask;
% reduce the blob to a central line
tracemask(:,:,c) = bwskel(mask,'minbranchlength',10);
end
% show them (doesn't really show up on the forum)
montage(permute(tracemask,[1 2 4 3]),'size',[numtraces 1], ...
'bordersize',3,'backgroundcolor','m')
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the plot box is just the image geometry
x1 = 1;
x2 = size(inpict,2);
y1 = 1;
y2 = size(inpict,1);
% get all three curves
% i'm using a cell array, since the vector pairs
% are not necessarily the same length
% if you need them to be represented on a common abcissa
% you can use interp1() to do the interpolation
xdata = cell(3,1);
ydata = cell(3,1);
for c = 1:numtraces
trace = tracemask(:,:,c);
% convert the trace to xy data
[y0 x0] = find(trace,1); % find initial point
B = bwtraceboundary(trace,[y0 x0],'E'); % [y x]
x = B(:,2);
y = B(:,1);
% rescale the trace to data coordinates
xrange = tdiv(c)*xdivs + toffset(c);
yrange = vdiv(c)*ydivs + voffset(c);
x = xrange(1) + diff(xrange)*(x-x1)/(x2-x1);
y = yrange(1) + diff(yrange)*((y2-x1) - (y-x1))/(y2-x1);
% get rid of nonunique points
% this restricts us to capturing curves which
% represent single-valued functions of x
[x,idx,~] = unique(x);
y = y(idx);
xdata{c} = x;
ydata{c} = y;
end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot
plot(xdata{1},ydata{1},'r'); grid on; hold on
plot(xdata{2},ydata{2},'g')
xlim(xrange)
ylim(yrange)
Either way, you need to include the trace offsets. Also, your scope divisions are clearly not what you say they are.

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by