Hello friends, I hope you all are doing great. In today’s tutorial, I am going to show you How to do ECG Digitization in MATLAB. If you are new to ECG signals then you should have a look at Introduction to ECG. I have also posted many different simulations on ECG in which I have extracted different features of ECG signals but in today’s tutorial, we are gonna extract the ECG signal itself from its image. I have also saved this ECG signal in a txt file so that you can use it. This code is not open source and you can buy it from our shop by clicking the above button.
I have designed a GUI in MATLAB and it will take image of ECG signal as an input and then will give the digital form of that ECG signal as an output. There are few restrictions on this code and its not necessary that it will work on all images of ECG signal, but I am sure it will work on most of them. I have also added three images in the folder which works great with this code. You should also have a look at ECG Simulation using MATLAB and ECG Averaging in MATLAB. So, let’s get started with ECG Digitization in MATLAB:
ECG Digitization in MATLAB
- When you will buy this MATLAB code, you will get an rar file.
- Extract this rar file and it will contain below files in it:
- You need to run Main.m file which is a MATLAB file.
- Open this file in MATLAB and run it.
- If everything goes fine then it will open up as shown in below figure:
- Click this button which says Load Image File.
- When you click this button, it will open up a dialog box as shown in below figure:
- Here you need to select the image of ECG signal, which you want to digitize.
- So, I am selecting ECG1.png and the results are shown in below figure:
- The first axes is showing the ECG Image file as it is.
- I have converted this ECG Image File into Gray Scale which is shown in axes 2.
- Further, I have converted this Dray Scale Image into Binary Image which is shown in axes 3.
- If you have noticed we have a blue line in ECG Binary Image.
- I have added this line and taken it as an x-axis, the algo is reading the values of black pixels and then subtracting it from this x axis line.
- In this way, I am getting my complete ECG Signal and the Axes 4, which is named as ECG Signal, is displaying this digital ECG Signal.
- I have converted pixels into mV, which you can change by yourself in the code.
So, that was all about ECG Digitization in MATLAB. If you got into any trouble regarding this project then you can ask in comments and I will try my best to resolve them. Thanks for reading !!! 🙂