Proceedings of the 2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 
INTERNATIONAL JOURNAL OF ELECTRONICS AND 
17 – 19, July 2014, Mysore, Karnataka, India 
COMMUNICATION ENGINEERING  TECHNOLOGY (IJECET) 
ISSN 0976 – 6464(Print) 
ISSN 0976 – 6472(Online) 
Volume 5, Issue 8, August (2014), pp. 200-207 
© IAEME: http://www.iaeme.com/IJECET.asp 
Journal Impact Factor (2014): 7.2836 (Calculated by GISI) 
www.jifactor.com 
IJECET 
© I A E M E 
PERFORMANCE ANALYSIS OF ECG QRS COMPLEX DETECTION USING 
200 
 
MORPHOLOGICAL OPERATORS 
Ms. Manju S Hadagali1, Mrs. Laxmi Pai2 
1(Student, M.Tech, ECE Department, Srinivas Institute of Technology, Mangalore. India) 
2(Asst. Professor, ECE Department, Srinivas Institute of Technology, Mangalore. India) 
ABSTRACT 
The QRS complex detection is one of the most essential tasks in ECG analysis. This paper 
presents an algorithm of QRS complex detection using morphological operators. The proposed 
algorithm utilizes the dilation-erosion mathematical morphology filtering to suppress the background 
noise and remove the baseline drift. Then the modulus accumulation is used to enhance the signal 
and improve signal-to-noise ratio. The performance of the algorithm is evaluated with MIT-BIH 
arrhythmia database and wearable ECG Data. The algorithm gets the high detection rate and high 
speed. 
Keywords: Body Sensor Networks (Bsns), Electrocardiogram (ECG), Mathematical Morphology, 
QRS Detection. 
1. INTRODUCTION 
The QRS complex is the most striking waveform within the electrocardiogram (ECG). Since 
it reflects the electrical activity within the heart during the ventricular contraction, the time of its 
occurrence as well as its shape provide much information about the current state of the heart [1], [2]. 
Among the three main components known as P, QRS and T waves for a typical ECG, the most 
characteristic wave set is the QRS complex recording the depolarization phenomenon of the 
ventricles [2]-[4]. The detection of QRS complex is the first step towards analyzing ECG signal. 
Therefore, reliable and accurate detection of QRS complex is gaining momentum nowadays. 
Recently, much research effort has been devoted into the development and evaluation of QRS 
detectors. 
The QRS detector is used for analysing QRS complex signal (or ECG signal, is shown in Fig 
1). The QRS detector allows doctor to calculate and fine-tune heart beat rate of patients. Among the 
noises plaguing the ECG are the power-line interference: 50/60 Hz pickup and harmonics from the 
power cord; electrode contact noise: baseline drift due to variable contact between the electrode and
Proceedings of the 2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 
17 – 19, July 2014, Mysore, Karnataka, India 
the skin; motion artifacts: shifts in the baseline caused by changes in the electrode-skin impedance; 
muscle contraction: electromyogram-type signals (EMG); respiration causing drift in the baseline; 
and electromagnetic interference and noise coupled from other electronic devices. For meaningful 
and accurate these noise sources. Hence, a reliable on-the-fly QRS detection method with low 
hardware cost, high sensitivity, and good noise susceptibility is of urgent need. 
201 
 
Fig 1: QRS complex with P, Q, R, S, T points 
Much effort has been given to the frequency-based ECG filtering algorithms for QRS 
detection, i.e., a band-pass filter with a center frequency in the range of 10–17 Hz. After passing the 
filter, the signal may be squared or averaged over a number of samples to obtain the place of QRS 
waves. But these techniques suffer from the fact that frequency bands of the noise/other components 
such as P/T waves overlap with that of QRS complex. In addition, in order to accurately detect the 
QRS, prior knowledge of frequency spectrums of different components in the recorded ECG signal is 
required through an additional training process. 
A new approach to QRS detection is presented in this paper which is based on mathematical 
morphology. In this approach one channel is used at a time and the QRS events are detected by the 
application of a morphological operator to the ECG signal. This operator works as a peak-valley 
extractor [5]. The shape of the signal components (peaks, valleys) that are extracted is determined by 
the shape of the structuring clement. This approach constitutes a mathematically formal, accurate, 
and robust scheme for QRS detection. Moreover, it is computationally very efficient since it employs 
only morphological operations (openings, closings) which are implemented as comparisons 
(min/max operators). Morphological operators were developed in the image analysis held but they 
are not yet as widely used in one-dimensional (1-D) signal processing tasks. An efficient approach to 
impulsive noise suppression and baseline correction in ECG signals using morphological operators is 
described in [6]. 
This remainder of paper is organized as follows. In Section 2, a brief introduction of 
mathematical morphology filtering is given, which serves as a basis for the proposed algorithm. 
Section 3 presents the new algorithm and discusses the details of the algorithm. What follows is the 
VLSI architecture design and implementation in Section 4. The evaluation of the algorithm is done in 
Section 5. Conclusion remarks are drawn in Section 6.
Proceedings of the 2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 
17 – 19, July 2014, Mysore, Karnataka, India 
2. CONCEPTS OF MATHEMATICAL MORPHOLOGY 
202 
 
Mathematical morphology, which is based on set operations, provides an approach to the 
development of non- linear signal processing operators that incorporate shape information of a signal 
[5], [10]. In mathematical morphological operations, the result of a set transformed by another set 
depends on the shapes of the two sets involved. The shape of a signal is determined by the values 
that the signal takes on. The shape information of the signal is extracted by using a structuring 
element to operate on the signal. 
Morphological operators were developed in the image processing field for machine vision 
and medical imaging applications. Morphological operators have been used in a limited way for 
background normalization of biological signals. Operators that are used to process the ECG data for 
noise suppression and background normalization as described in this paper are known in the image 
processing literature as gray-scale morphological operators [11]. There are two basic morphological 
operators: erosion and dilation [12]. These operators are usually applied in tandem; opening and 
closing are two derived operations defined in terms of erosion and dilation. 
Dilation : f Å g(n) = max( f (n − i) + g(i)) (1) 
Erosion : fQg(n) = min( f (n + i) − g(i)) (2) 
Opening : f o g(n) = ( fQg)Å g(n) (3) 
Closin g : f * g(n) = ( f Å g)Qg(n) (4) 
Top − hat :That( f (n)) = f (n) − f o g(n) (5) 
Bottom − hat : Bhat( f (n)) = f (n) − f * g(n) (6) 
where i indicates the th i element in a length L structure element, and g(n) is a predefined structure 
element. 
3. PROPOSED QRS DETECTION ALGORITHM 
QRS complexes are composed of a group of consecutive positive and negative peaks. 
Mathematical morphological technology extracts the effective information based on shapes in the 
image. It leads to better reproducible results because of the strong mathematical foundation. The 
proposed morphology operator filtering plays the most critical role in the proposed algorithm which 
removes the noise in ECG signal. Modulus and accumulation further enhance the QRS signal leading 
to accurate QRS detection. 
The block diagram of the proposed algorithm is shown in Fig. 2. The proposed morphology 
operator filtering plays the most critical role in the proposed algorithm which removes the noise and 
baseline drift and suppresses the P/T waves in ECG signal. Then the multi-pixel modulus 
accumulation is used to enhance the QRS complex. Finally, the threshold is applied to decide the 
heart rate. The detailed discussions on each section in Fig. 2 are presented in the following 
subsections. The standard MIT/BIH ECG database [13] and our own wearable ECG data are used to 
demonstrate the superiority of proposed QRS detector.
Proceedings of the 2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 
17 – 19, July 2014, Mysore, Karnataka, India 
h ( n ) = f Å g n + fQ g n (7) 
203 
 
Fig. 2: Block diagram of proposed algorithm 
3.1 MORPHOLOGICAL FILTER 
Dilation expands an image object and erosion shrinks it. In most applications, opening is used 
to suppress peaks while closing is used to suppress pits. Here, in order to detect QRS complex 
accurately and quickly, a peak extractor is defined only based on basic dilation and erosion 
morphological operators, instead of a series of advanced openings and closings as in existing 
literature [5]–[10]. It can be written as 
[ ( ) ( ) ] 
1 
2 
v(n) = f (n) − h(n) (8) 
The shape (or slope) of the structure element is the most significant factor, herein the smaller 
slope performs better in terms of removing noise, but with a larger reduction in the amplitude of 
resulted signal. The less significant item is the length of the structure element (i.e., the assumed 
duration of the QRS complex), which varies with patient and placement of the electrodes, and longer 
structure element turns out to lead to slightly better performance in terms of noise reduction, but with 
a small decrease in amplitude of QRS complex. The least significant item is the amplitude of the 
structure item, which the filter performance is the least sensitive to. Hence, in our selections, more 
considerations are given in terms of the tradeoff between computational complexity, effectiveness, 
and amplitude of resulted signal when determining the parameters of structure element. Considering
Proceedings of the 2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 
17 – 19, July 2014, Mysore, Karnataka, India 
the simplicity and similar shape, we select the triangle structure element by the optimization, defined 
as 

 
  
 
0.1 Max , Max 
3 
= = 
0.3 , 3 7 
T (11) 
204 
 
[ ] 
[ ] 
 
 
 
 
 
=
− 
* − 
 
+ 
* 
= 
2 
, 
( 1) 
2 1 
2 
, 
( 1) 
2 
( ) 
k L 
L 
A k 
k L 
L 
A k 
g k 
(9) 
L is the length of structure element, A is the amplitude, and k= 1,2,3…………..L. 
3.2 MODULUS AND ACCUMULATION 
The absolute value of the above output is then combined by multiple-frame accumulation, 
which is much alike energy transformation [14], [15]. The energy accumulation process is expressed 
as
+ 
 [ ] 
( ) ( ) 
s n v i
= − 
= 
2 
2 
q 
n 
q 
i n 
(10) 
The value of q should correspond to the possible maximum duration of normal QRS 
complex. This step further enhances the filtered ECG signal to make QRS peaks easy to identify. 
3.3 THRESHOLD AND DECISIONS 
An adaptive threshold is used as the decision function in connection with the proposed 
transformation for QRS detection. Usually, the threshold levels are computed signal dependent such 
that an adaption to changing signal characteristics is possible. For the signal produced by (9), it is 
proposed that the required adaptive threshold is a function of the maximum of the transformed ECG 
waveform .The guideline in selecting the threshold is given by 
 
  
 
 
 
Max Max 
 
= 
0.13 Max , Max 
7 
where Max is determined from the current signal segment which is within the range of 
millivolts. The upper and lower bounds of Max will be subject to the selection of structure elements. 
4. CIRCUIT IMPLEMENTATION 
The design strategy of the hardware implementation is to reduce as much computation load as 
possible. The proposed VLSI architecture consists of shift registers, Rom, adder, comparator. The 
proposed algorithm can be easily implemented by shift registers, adder, comparator, and some 
control logics. The pivotal modules of this algorithm are the dilation and erosion. The opening and 
closing operations can be fulfilled by cascading the dilation and erosion units together. The rest parts 
of the circuits can be easily implemented with shift registers and adders, and therefore are not 
discussed in detail in this paper. The overall implementation of proposed algorithm is verified using 
the Xilinx 12.2 Spartan III FPGA. The heart of Spartan-3 is XC3S400 based development board.

Performance analysis of ecg qrs complex detection using morphological operators

  • 1.
    Proceedings of the2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 INTERNATIONAL JOURNAL OF ELECTRONICS AND 17 – 19, July 2014, Mysore, Karnataka, India COMMUNICATION ENGINEERING TECHNOLOGY (IJECET) ISSN 0976 – 6464(Print) ISSN 0976 – 6472(Online) Volume 5, Issue 8, August (2014), pp. 200-207 © IAEME: http://www.iaeme.com/IJECET.asp Journal Impact Factor (2014): 7.2836 (Calculated by GISI) www.jifactor.com IJECET © I A E M E PERFORMANCE ANALYSIS OF ECG QRS COMPLEX DETECTION USING 200 MORPHOLOGICAL OPERATORS Ms. Manju S Hadagali1, Mrs. Laxmi Pai2 1(Student, M.Tech, ECE Department, Srinivas Institute of Technology, Mangalore. India) 2(Asst. Professor, ECE Department, Srinivas Institute of Technology, Mangalore. India) ABSTRACT The QRS complex detection is one of the most essential tasks in ECG analysis. This paper presents an algorithm of QRS complex detection using morphological operators. The proposed algorithm utilizes the dilation-erosion mathematical morphology filtering to suppress the background noise and remove the baseline drift. Then the modulus accumulation is used to enhance the signal and improve signal-to-noise ratio. The performance of the algorithm is evaluated with MIT-BIH arrhythmia database and wearable ECG Data. The algorithm gets the high detection rate and high speed. Keywords: Body Sensor Networks (Bsns), Electrocardiogram (ECG), Mathematical Morphology, QRS Detection. 1. INTRODUCTION The QRS complex is the most striking waveform within the electrocardiogram (ECG). Since it reflects the electrical activity within the heart during the ventricular contraction, the time of its occurrence as well as its shape provide much information about the current state of the heart [1], [2]. Among the three main components known as P, QRS and T waves for a typical ECG, the most characteristic wave set is the QRS complex recording the depolarization phenomenon of the ventricles [2]-[4]. The detection of QRS complex is the first step towards analyzing ECG signal. Therefore, reliable and accurate detection of QRS complex is gaining momentum nowadays. Recently, much research effort has been devoted into the development and evaluation of QRS detectors. The QRS detector is used for analysing QRS complex signal (or ECG signal, is shown in Fig 1). The QRS detector allows doctor to calculate and fine-tune heart beat rate of patients. Among the noises plaguing the ECG are the power-line interference: 50/60 Hz pickup and harmonics from the power cord; electrode contact noise: baseline drift due to variable contact between the electrode and
  • 2.
    Proceedings of the2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 17 – 19, July 2014, Mysore, Karnataka, India the skin; motion artifacts: shifts in the baseline caused by changes in the electrode-skin impedance; muscle contraction: electromyogram-type signals (EMG); respiration causing drift in the baseline; and electromagnetic interference and noise coupled from other electronic devices. For meaningful and accurate these noise sources. Hence, a reliable on-the-fly QRS detection method with low hardware cost, high sensitivity, and good noise susceptibility is of urgent need. 201 Fig 1: QRS complex with P, Q, R, S, T points Much effort has been given to the frequency-based ECG filtering algorithms for QRS detection, i.e., a band-pass filter with a center frequency in the range of 10–17 Hz. After passing the filter, the signal may be squared or averaged over a number of samples to obtain the place of QRS waves. But these techniques suffer from the fact that frequency bands of the noise/other components such as P/T waves overlap with that of QRS complex. In addition, in order to accurately detect the QRS, prior knowledge of frequency spectrums of different components in the recorded ECG signal is required through an additional training process. A new approach to QRS detection is presented in this paper which is based on mathematical morphology. In this approach one channel is used at a time and the QRS events are detected by the application of a morphological operator to the ECG signal. This operator works as a peak-valley extractor [5]. The shape of the signal components (peaks, valleys) that are extracted is determined by the shape of the structuring clement. This approach constitutes a mathematically formal, accurate, and robust scheme for QRS detection. Moreover, it is computationally very efficient since it employs only morphological operations (openings, closings) which are implemented as comparisons (min/max operators). Morphological operators were developed in the image analysis held but they are not yet as widely used in one-dimensional (1-D) signal processing tasks. An efficient approach to impulsive noise suppression and baseline correction in ECG signals using morphological operators is described in [6]. This remainder of paper is organized as follows. In Section 2, a brief introduction of mathematical morphology filtering is given, which serves as a basis for the proposed algorithm. Section 3 presents the new algorithm and discusses the details of the algorithm. What follows is the VLSI architecture design and implementation in Section 4. The evaluation of the algorithm is done in Section 5. Conclusion remarks are drawn in Section 6.
  • 3.
    Proceedings of the2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 17 – 19, July 2014, Mysore, Karnataka, India 2. CONCEPTS OF MATHEMATICAL MORPHOLOGY 202 Mathematical morphology, which is based on set operations, provides an approach to the development of non- linear signal processing operators that incorporate shape information of a signal [5], [10]. In mathematical morphological operations, the result of a set transformed by another set depends on the shapes of the two sets involved. The shape of a signal is determined by the values that the signal takes on. The shape information of the signal is extracted by using a structuring element to operate on the signal. Morphological operators were developed in the image processing field for machine vision and medical imaging applications. Morphological operators have been used in a limited way for background normalization of biological signals. Operators that are used to process the ECG data for noise suppression and background normalization as described in this paper are known in the image processing literature as gray-scale morphological operators [11]. There are two basic morphological operators: erosion and dilation [12]. These operators are usually applied in tandem; opening and closing are two derived operations defined in terms of erosion and dilation. Dilation : f Å g(n) = max( f (n − i) + g(i)) (1) Erosion : fQg(n) = min( f (n + i) − g(i)) (2) Opening : f o g(n) = ( fQg)Å g(n) (3) Closin g : f * g(n) = ( f Å g)Qg(n) (4) Top − hat :That( f (n)) = f (n) − f o g(n) (5) Bottom − hat : Bhat( f (n)) = f (n) − f * g(n) (6) where i indicates the th i element in a length L structure element, and g(n) is a predefined structure element. 3. PROPOSED QRS DETECTION ALGORITHM QRS complexes are composed of a group of consecutive positive and negative peaks. Mathematical morphological technology extracts the effective information based on shapes in the image. It leads to better reproducible results because of the strong mathematical foundation. The proposed morphology operator filtering plays the most critical role in the proposed algorithm which removes the noise in ECG signal. Modulus and accumulation further enhance the QRS signal leading to accurate QRS detection. The block diagram of the proposed algorithm is shown in Fig. 2. The proposed morphology operator filtering plays the most critical role in the proposed algorithm which removes the noise and baseline drift and suppresses the P/T waves in ECG signal. Then the multi-pixel modulus accumulation is used to enhance the QRS complex. Finally, the threshold is applied to decide the heart rate. The detailed discussions on each section in Fig. 2 are presented in the following subsections. The standard MIT/BIH ECG database [13] and our own wearable ECG data are used to demonstrate the superiority of proposed QRS detector.
  • 4.
    Proceedings of the2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 17 – 19, July 2014, Mysore, Karnataka, India h ( n ) = f Å g n + fQ g n (7) 203 Fig. 2: Block diagram of proposed algorithm 3.1 MORPHOLOGICAL FILTER Dilation expands an image object and erosion shrinks it. In most applications, opening is used to suppress peaks while closing is used to suppress pits. Here, in order to detect QRS complex accurately and quickly, a peak extractor is defined only based on basic dilation and erosion morphological operators, instead of a series of advanced openings and closings as in existing literature [5]–[10]. It can be written as [ ( ) ( ) ] 1 2 v(n) = f (n) − h(n) (8) The shape (or slope) of the structure element is the most significant factor, herein the smaller slope performs better in terms of removing noise, but with a larger reduction in the amplitude of resulted signal. The less significant item is the length of the structure element (i.e., the assumed duration of the QRS complex), which varies with patient and placement of the electrodes, and longer structure element turns out to lead to slightly better performance in terms of noise reduction, but with a small decrease in amplitude of QRS complex. The least significant item is the amplitude of the structure item, which the filter performance is the least sensitive to. Hence, in our selections, more considerations are given in terms of the tradeoff between computational complexity, effectiveness, and amplitude of resulted signal when determining the parameters of structure element. Considering
  • 5.
    Proceedings of the2nd International Conference on Current Trends in Engineering and Management ICCTEM -2014 17 – 19, July 2014, Mysore, Karnataka, India the simplicity and similar shape, we select the triangle structure element by the optimization, defined as 0.1 Max , Max 3 = = 0.3 , 3 7 T (11) 204 [ ] [ ] =
  • 6.
    − * − + * = 2 , ( 1) 2 1 2 , ( 1) 2 ( ) k L L A k k L L A k g k (9) L is the length of structure element, A is the amplitude, and k= 1,2,3…………..L. 3.2 MODULUS AND ACCUMULATION The absolute value of the above output is then combined by multiple-frame accumulation, which is much alike energy transformation [14], [15]. The energy accumulation process is expressed as
  • 7.
    + [] ( ) ( ) s n v i
  • 8.
    = − = 2 2 q n q i n (10) The value of q should correspond to the possible maximum duration of normal QRS complex. This step further enhances the filtered ECG signal to make QRS peaks easy to identify. 3.3 THRESHOLD AND DECISIONS An adaptive threshold is used as the decision function in connection with the proposed transformation for QRS detection. Usually, the threshold levels are computed signal dependent such that an adaption to changing signal characteristics is possible. For the signal produced by (9), it is proposed that the required adaptive threshold is a function of the maximum of the transformed ECG waveform .The guideline in selecting the threshold is given by Max Max = 0.13 Max , Max 7 where Max is determined from the current signal segment which is within the range of millivolts. The upper and lower bounds of Max will be subject to the selection of structure elements. 4. CIRCUIT IMPLEMENTATION The design strategy of the hardware implementation is to reduce as much computation load as possible. The proposed VLSI architecture consists of shift registers, Rom, adder, comparator. The proposed algorithm can be easily implemented by shift registers, adder, comparator, and some control logics. The pivotal modules of this algorithm are the dilation and erosion. The opening and closing operations can be fulfilled by cascading the dilation and erosion units together. The rest parts of the circuits can be easily implemented with shift registers and adders, and therefore are not discussed in detail in this paper. The overall implementation of proposed algorithm is verified using the Xilinx 12.2 Spartan III FPGA. The heart of Spartan-3 is XC3S400 based development board.