Convert a wave image to x-y function matlab

本文介绍了一种将示波器捕获的波形图像转换为数学表示的方法,便于利用MATLAB等工具进行进一步分析。通过图像处理技术提取波形坐标,并将其转换为时间和电压坐标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[x,y]=imwtoxy(signal,V,T,px)
function [x,y]=imwtoxy(signal,V,T,px)
%This function can be used to convert an image of a wave captured 
%from an oscilloscope to its x-y representation Which may be used to find
%the mathematical properties of the wave by matlab functions.
%--------------------------------------------------------------------------
% Simples code of the function:
% Signal = image names with its kind .... example 'wave.jpg'
% V = Volt per div in the oscilloscope panel
% T = second per div in the oscilloscope panel
% px = Number of pixel per centimeters in the oscilloscope grid image
% x = Time vector of the result AC voltage wave 
% y = Alternating amplitude vector of the result AC voltage wave
%--------------------------------------------------------------------------
% step 1: Read wave image and convert it to sharp bright one
xim=imread(signal);
x1=xim(:,:,1);
x2=im2bw(x1);
x3=bwmorph(x2,'skel',inf);
%--------------------------------------------------------------------------
% step 2: Find the coordinates of the two edges of the wave image in its
% matrix representation (pixel representation)
n=size(x1);
m=1;
for j=1:1:n(2)
c=0;
for i=1:1:n(1)
if x3(i,j)==1
c=c+1;
k=i;            
end
end
if c~=0
y1(m)=c-k;
y2(m)=-k;
x(m)=j;
m=m+1;      
end   
end
y1=y1-min(y1);
y2=y2-min(y2);
x=x-min(x);
%--------------------------------------------------------------------------
%step 3 :Convert waves axis scale from pixel to centimeters and split     
%y1 and y2 into positive and negative part
y1=y1/px;
y2=y2/px;
y1=y1-max(y1)/2;
y2=y2-max(y2)/2;
x=x/px; 
%--------------------------------------------------------------------------
%step 4 :Convert waves axis scale from centimeters to volt and second
y1=y1*V; 
y2=y2*V; 
x=x*T;
%--------------------------------------------------------------------------
%step 5 :Find the middle point y between y1 and y2  
dy=y1-y2;
y=y1-dy/2;
%--------------------------------------------------------------------------
%step 6 : Find smooth representation of y axis 
y=smooth(x,y,0.01,'rloess');
y=y';
%--------------------------------------------------------------------------
%step 7 : plotting the result wave with its image
subplot 211;imshow(x1);xlabel('Sine wave captured from an oscilloscope')
subplot 212;p=plot(x,y);grid on
xlabel('Time (sec)'); ylabel('wave Amplitude(volt)');
set(p,'Color','red','LineWidth',2)
end
%--------------------------------------------------------------------------
%The function tested with sine wave image of size 5M pixel captured by
%digital camera from analoge oscilloscope with 
%V=50/1000 volt/div and T=0.5/1000 second/div. 
%The size 5M pixel produce px=178 pixel/div.
%A.Y.Iwyead , Sep 29, 2011
                                        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值