ECG Digitization by Classical Digital Image Processing

Federico Wadehn1, Remo Schneider2, Janic Aeschbacher2
1Zurich University of Applied Sciences, 2ZHAW School of Engineering


Abstract

Aims: The goal of this work was to develop an automatized image processing pipeline for extracting ECG signal segments from a 12-lead ECG paper scan.

Methods: For digitizing ECG images, we devised an automatized image processing pipeline. First, the ECG image is binarized and the vertical and horizontal grid lines are detected using the Hough transform. The detected lines are used for calibration, that is, for determining how many pixels form a large square (corresponding to 0.2 s horizontally and 0.5 mV vertically). In addition, any image rotation is corrected. The next step is an optical character recognition to determine the location and content. Following this, the grid lines and the text are removed. The gaps in the ECG signals that arise due to these image processing steps are mitigated using morphological operations. The final step is to perform an iterative (one iteration per signal row) column-wise search for the first white pixel, starting from the bottom. Once all columns have been iterated through, all pixels inside a bounding box around the detected signal are set to black. This procedure is iterated until all signal rows have been identified. The ECG signal rows are finally segmented, assuming a duration of 2.5 s per lead and that the first three rows and four columns contain the 12-lead ECG, and the last 0-2 rows contain a 10s long ECG segments. The final step is high-pass filtering of each ECG signal using a Butterworth high-pass filter with a cutoff frequency of 0.05 Hz.

Results: We performed an evaluation with a test set using 100 ECG waveforms from the PTB-XL database using the ECG-Image-Kit synthetic ECG image generator for generating ECG images. Using the evaluation code provided in the PhysioNet 2024 Challenge, we obtained an SNR of -2.44 dB.