Code covered by the BSD License  

Highlights from
Oscilloscope

from Oscilloscope by aasim Azooz
This software helps in obtaining numerical data of an oscilloscope trace

[x,y]=oscilloscope(x_sensetivity,y_sensetivity,picture_name,number_of_contours)
function [x,y]=oscilloscope(x_sensetivity,y_sensetivity,picture_name,number_of_contours)
close all% prepare the desktop by closing any plots from prevoius runs
warning off
u=picture_name;%suppres warrning about image size
x=imread(u); % Loading the image
figure
imshow(x); %Showing the image
x=double(x); % Change to 16 bits
S=size(x);% statments 8 to 20 set image coordinates reference points
x11(1)=0;
x11(2)=S(2);
x11(5)=0;
x11(6)=0;
y11(1)=S(1);
y11(2)=S(2);
y11(5)=S(1);
y11(6)=0;
[x11(3:4),y11(3:4)]=ginput(2); %Selecting reference and normalization points
x11(7)=x11(3);
y11(7)=y11(3);
[x11(8),y11(8)]=ginput(1);
xshift=x11(3); % Finding pixel for x=0
yshift=y11(5)-y11(7); % finding pixel for y=0
xunit=abs(x11(4)-x11(3)); % Calculating pixels/unit x
yunit=abs(y11(8)-y11(7)); % Calculating pixels/unit y
subplot(3,1,1)
imagesc(x(:,:,1)); % Showing Red matrix for colored pictures or the whole picture for Black and white
S=size(x);
n=1;
if length(S)==3 % Checking if colored or black and white
    % continue for green and blue for colored pictures
subplot(3,1,2)
    imagesc(x(:,:,2));%showing matrix image for green
subplot(3,1,3)
imagesc(x(:,:,3));% showing matrix image for blue
n=input('choose 1,2,or 3??   ');% prompting to select a view by typing 1,2 or 3
end
z=squeeze(x(:,:,n)); %select a two dimentional array corresponging to the Red Green or Blue
figure
[C,H]=contour(z,number_of_contours);% plot the contour map of the color distribution within the picture
clabel(C,H,'manual')% activating the mouse to find the contour level
v=input('what is your contour value ???   ');% prompting to enter contour level value selected
x=contour(z,[v v]);%calculte the desired contour points
n=1;% statments 44 to 60 are for decoding the contour matrix
xx=[];
yy=[];
x1=squeeze(x(1,:));
y1=squeeze(x(2,:));
for i=1:1000
x0=y1(n);
if length(x1)>100
xx1=x1(n+1:n+x0);
yy1=y1(n+1:n+x0);
end
xx=[xx,xx1];
yy=[yy,yy1];
n=n+x0+1;
if n>=length(x)
    break
end
end
% statments 63 to 68 are for calibrating pixels to voltage and/or time
yy=y11(5)-yy;
xx=xx-xshift;
yy=yy-yshift;
xx=xx/xunit;
yy=yy/yunit;
xx=xx*x_sensetivity;
yy=yy*y_sensetivity;
[xx,yy]=treat(xx,yy);% sorting data in ascending order in x
[xxx1,yyy1]=minima(xx,yy);% evaluating lower contour boundary
[xxx2,yyy2]=maxima(xx,yy);% evaluating upper contour boundary
kkk=floor(length(yyy2)/2);% statments 72 to 76 for bringinging the data to midway points between upper and lower contour boundaries
width=abs(yyy2(1:kkk)-yyy1(1:kkk));
ww=mean(width)/2;
    x=xxx1;
    y=yyy1+ww;
  figure
    plot(x,y)% plotting pre-final data
    z=input('Does the trace needs any cleaning?? TYPE 1 for YES  ')% prompting for any stray points removal
    if z==1
        [x,y]=clean(x,y);
    end
  grid

Contact us at files@mathworks.com