您现在的位置是:首页 > 电源

ECG信号数字化处理技术

2022-08-10 02:07:21

ECG信号是一维的数据。一般被记录在热敏纸上。不便于保存和处理。可以先用扫描仪,至少300DPI的分辨率,扫描下来。

使用PHOTOSHOP的旋转将图旋转到正确方向。使用魔棒工具 容差50 连续 将相应图线选出。反选后将背景的格子颜色,及说明去除。图像模式改为灰度,去除颜色。再交图像模式改为位图。50%阈值。另存成bmp文件。

然后使用下面的程序转换。bmp文件被读入MATLAB中,并查找非空边沿,然后再做一维数字化。bmp图像转换成对应文件名的文本文件,文本文件可以导入EXCEL或其它可以接受数据的程序中。数据以科学计数法表示。

% remove blank line and digitalize
% try to find 4 boundery and put it to
% an txt file
% 4 bounder is bup bdown bleft bright
%
% usage: removeblank 'filename' filename must be a bmp file

funcTIon y = removeblank( x )
a = imread(x,'bmp');
for i = 1 : length(a(:,1))
??? if(length(find(a(i,:))) ~= 0)
??????? bup = i;
??????? break;
??? end
end
for i = length(a(:,1)) : -1 : 1
??? if(length(find(a(i,:))) ~= 0)
??????? bdown = i;
??????? break;
??? end
end?
for i = length(a(1,:)) : -1 : 1
??? if(length(find(a(:,i))) ~= 0)
??????? bright = i;
??????? break;
??? end
end?
??
for i = 1 : length(a(1,:))
??? if(length(find(a(:,i))) ~= 0)
??????? bleft = i;
??????? break;
??? end
end;
% 4 boundery found


fid = fopen(['dg',x,'.txt'],'W');

for i = bup : bdown
??? b = find(a(i, bleft : bright));
???
??? if(length(b) == 0)
??????? c(i - bup + 1) = c(i - bup)
??? else
??? c(i-bup + 1) = sum(b)/(length(b));
end
fprintf(fid,'%6d\n',c(i-bup + 1));

end;
plot(c);
fclose(fid);
%imwrite(a(bup : bdown, bleft : bright),['rb',x] ,'bmp');