ISSN: 2641-3027
Biomed Sci Eng
Research Article       Open Access      Peer-Reviewed

The QRS complex detection using morphological filtering

Taouli SA* and Bereksi-Reguig F

Department of Biomedical Genius, Faculty of Technology, University Aboubekr-Belkaid, Algeria
*Corresponding author: Taouli SA, Department of Biomedical Genius, Faculty of Technology, University Aboubekr-Belkaid, Algeria, E-mail:
Received: 28 November, 2018 | Accepted: 24 January, 2019 | Published: 25 January, 2019

Cite this as

Taouli SA, Bereksi-Reguig F (2019) The QRS complex detection using morphological filtering. Biomed Sci Eng 5(1): 001-006. DOI: 10.17352/abse.000011

This article presents a method of QRS complex detection and more precisely the R wave in an electrocardiogram (ECG) based on the mathematics morphology which calls upon the four operators’ morphology, erosion, dilation, opening and closing. These operators are combined with a window relocated which is called the structuring element. Morphological filtering uses the structuring element to extract the shape information from ECG signal. The effectiveness of the proposed algorithm is tested by using recordings obtained from the MIT-BIH arrhythmia database. Experiment results show that the proposed algorithm outperforms the other algorithms.


The ECG signal is characterized by five peaks and valleys labelled by the letters P, Q, R, S, T as shown in figure 1.

The QRS complex is the most prominent wave component within the electrocardiogram. It reflects the electrical activity of heart during the ventricular contraction and the time of its occurrence.

A great number of methods were proposed for detection of the waves of ECG signal [1-7]. The majority of these methods are based on filtering or the thresholding adaptive, which shows the limitation of the application. Very few algorithms function well for the detection of all the landmarks such as the beginning and the end of the P wave, the T wave and QRS complex (also known under the name: extremes of the waves of ECG signal).

The principal disadvantage of filtering is that the variations of the frequency of the waves of ECG signal can influence its performance. This entrained being able a detection of false positions of the waves and consequently a bad detection of the QRS complex positions. In the same way the techniques of thresholding suffer their sensitivity to the noise which is high and a bad effectiveness in the treatment from odd morphologies (case of the R peaks reversed). Consequently, of the more elaborate techniques of treatment of the signals are necessary to facilitate the development of new algorithms of detection with a higher precision of detection.

Among these techniques the nonlinear filtering, which must be proven that the operators morphologies of dilation and erosion satisfy causality and the additive property of semi-group is required by the analysis of multi-scale [13-15] for signals of any dimension with local maxima and local minima which correspond to point singular.

The landmarks of ECG signal, such as the Q wave, the R peak, the S wave, the beginning and the end of the P wave and the T wave can be regarded as singular points [8].

Trahanias [9] use morphological mathematics for detecting RR peaks. Thus, a structuring element of similar triangular shape of the shape of the R wave and a fixed thresholding to extract the heart rhythm. In [10] present morphological filtering to suppress noise and baseline ECG signal. Sun et al. [11]. Use three steps to detect peak R: the morphological derivative called the gradient, the multi-scale morphological operations, and a thresholding that relies on the histogram.

The overall difference between our method and the method cited in [9] and [11] is the selection of the structuring element with respect to shape and size to extract information from the signal. Also, we did not use a thresholding but [9] and [11] uses thresholding to detect peak R. Thus, the morphological filtering algorithm remains fixed, to detect positive or negative peaks.

In our work, the algorithm developed for detection bench marks of the waves of ECG signal, based on Morphological Filtering (MF).

In morphological filtering [12], each signal is looked like a set, and the geometrical characteristics are modified by the morphological convolution of ECG signal with a structuring element, which is characterized by a simple form and the size. By varying the structuring element we can extract the various types of information starting from ECG signal. By the application of the mathematical morphology, defined in different operators morphology and the sensitivity of noise can be reduced by the method of the morphological filtering. Moreover, the problem of the deviation of position is existed in the techniques of the transformation of wavelets [6] but can be cancelled in the morphological transformation because of non-linearity.

Morphological filtering

A Morphological filtering is very widespread in the field of signal treatment and the image processing because of its robustness and its simple and fast calculation [8-12].

The mathematical morphology, based on operations of sets, provides an approach to the development of the nonlinear methods of treatment of the signals, in which the form of the information of a signal is, incorporated [14]. In these operations, the result of a whole of data transformed by another whole depends on the forms of the two implied sets. A structuring element must be designed according to the shape information of the signal which must be extracted.

There are two basic morphological operators: erosion ( Θ ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaeuiMdefacaGLOaGaayzkaaaaaa@3F23@ and dilation ( ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaeyyLIumacaGLOaGaayzkaaaaaa@3FB4@ .

The opening ( ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaeSigI8gacaGLOaGaayzkaaaaaa@3EE6@ and closing ( ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaeyOiGClacaGLOaGaayzkaaaaaa@3F31@ are the operators derived defined in terms from erosion and dilation [14,15].

These operators are described in detail in below with the corresponding mathematical expressions. In this article, f (n) indicates discrete ECG signal of N size points (Figure 1a), and symmetrical structuring element the M points.


The expression below definite the erosion of function f (n) (ECG) by a structuring element B:

( fΘB )( n )= min m=0,.......,M1 { f( n M1 2 +m )B( m ) } MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaamOzaiaayIW7cqqHyoqucaWGcbaacaGLOaGaayzkaaWaaeWaaeaacaWGUbaacaGLOaGaayzkaaGaeyypa0JaciyBaiaacMgacaGGUbWaaSbaaSqaaiaad2gacqGH9aqpcaaIWaGaaiilaiaac6cacaGGUaGaaiOlaiaac6cacaGGUaGaaiOlaiaac6cacaGGSaGaamytaiabgkHiTiaaigdaaeqaaOWaaiWaaeaacaWGMbWaaeWaaeaacaWGUbGaeyOeI0YaaSaaaeaacaWGnbGaeyOeI0IaaGymaaqaaiaaikdaaaGaey4kaSIaamyBaaGaayjkaiaawMcaaiabgkHiTiaadkeadaqadaqaaiaad2gaaiaawIcacaGLPaaaaiaawUhacaGL9baaaaa@6428@

Erosion is characterized by the reduction of the peaks of signal and widened transformation the valleys. This transformation ( Θ ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaeuiMdefacaGLOaGaayzkaaaaaa@3F23@ is an operator of shrinkage in which the values of fΘB MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaaiaadAgacaaMi8UaeuiMdeLaamOqaaaa@40DD@ are always lower than f.


The expression (2) below definite the dilation of the function f (noisy ECG) by a structuring element B:

( fB )( n )= max m=0,.......,M1 { f( n M1 2 +m )+B( m ) } MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaamOzaiaayIW7cqGHvksXcaWGcbaacaGLOaGaayzkaaWaaeWaaeaacaWGUbaacaGLOaGaayzkaaGaeyypa0JaciyBaiaacggacaGG4bWaaSbaaSqaaiaad2gacqGH9aqpcaaIWaGaaiilaiaac6cacaGGUaGaaiOlaiaac6cacaGGUaGaaiOlaiaac6cacaGGSaGaamytaiabgkHiTiaaigdaaeqaaOWaaiWaaeaacaWGMbWaaeWaaeaacaWGUbGaeyOeI0YaaSaaaeaacaWGnbGaeyOeI0IaaGymaaqaaiaaikdaaaGaey4kaSIaamyBaaGaayjkaiaawMcaaiabgUcaRiaadkeadaqadaqaaiaad2gaaiaawIcacaGLPaaaaiaawUhacaGL9baaaaa@64B0@

This transformation with for properties in the morphological filtering of filled the valleys and to widen the peaks of ECG signal. The dilation ( ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaeyyLIumacaGLOaGaayzkaaaaaa@3FB4@ is an operation of expansion in which the values of fB MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaaiaadAgacqGHvksXcaWGcbaaaa@3FDD@ are increasingly larger than f.


The opening is the application of the operator erosion then of the operator dilation with the same structuring element:

fB=fΘBB          (3) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaaiaadAgacqWIyiYBcaWGcbGaeyypa0JaamOzaiaayIW7cqqHyoqucaWGcbGaeyyLIuSaamOqaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGOaGaae4maiaabMcaaaa@5009@


Closing is the “opposite” operation of the opening, i.e. which one applies first of all dilation then erosion (always by keeping the same structuring element):

fB=fBΘB          (4) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaaiaadAgacqGHIaYTcaWGcbGaeyypa0JaamOzaiabgwPiflaadkeacqqHyoqucaWGcbGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabIcacaqG0aGaaeykaaaa@4EC4@

( fB ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaamOzaiabgkci3kaadkeaaiaawIcacaGLPaaaaaa@40E3@ is also less rich in detail than the function initial f.

This transformation by closing fills the valleys, removes holes. In general, the starting whole is not found because part of the form eliminated by erosion cannot be recreates by a dilation. The transformation of opening ( fB ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaamaabmaabaGaamOzaiablIHiVjaadkeaaiaawIcacaGLPaaaaaa@4098@ is more regular (less details) than the original signal f.

The transformation by opening operator removes the peaks but preserves the valleys.

The two operations of opening and closing are idempotent, i.e. that the result is invariant after iterations:

fB=fBB          (5) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaaiaadAgacqWIyiYBcaWGcbGaeyypa0JaamOzaiablIHiVjaadkeacqWIyiYBcaWGcbGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabIcacaqG1aGaaeykaaaa@4D6F@

fB=fBB          (6) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbnvMCYL2DLfgDOvMCaeXatLxBI9gBaerbd9wDYLwzYbItLDharuavP1wzZbItLDhis9wBH5garqqtubsr4rNCHbGeaGakY=3j0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadaabauaaaOqaaiaadAgacqGHIaYTcaWGcbGaeyypa0JaamOzaiabgkci3kaadkeacqGHIaYTcaWGcbGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabIcacaqG2aGaaeykaaaa@4E51@

The operators “closing” and “opening” behave like filters; one will speak about “Morphological Filter”.

Structuring element

After the selection of the operator morphology, the structuring element (SE) is the next component of the morphological analysis to define. Generally, only when the form of the signal is matched with those of the structuring element that the signal can be preserved. Consequently, the form, length (domain) and size it (amplitude) structuring element should be selected according to the signal to be analyzed. The forms of the structuring element can vary regularly or irregularly, such as a triangle, line (flat), or a half-circle.

Method Proposed

As that was described, the combination of the operator’s morphology «Closing + Ouverture» forms the morphological filter. The use of the operators’ morphology for the QRS complex detection was described [13]. Mathematical morphology is based on the limits of erosion and dilation.

To obtain the two functions eroded and dilated the f (n)

Whether, f : F→ I and B → I and b: B I, which are indicated the discrete functions, where the sets F and B are underlined by F = {0.1, …, N – 1} et B = {0.1, …., M - 1}. I is the sets of the integer.

The following formula illustrates the dilation of the function F (ECG filtered) by the structuring element B:

( fB )( m )= min n=0,.,M1 f( m+n )B( n ) for N>M and m=0,..,NM             (7) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXafv3ySLgzGmvETj2BSbqefm0B1jxALjhiov2Daebbfv3ySLgzGueE0jxyaibaiKc9yrVq0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadiqacqaaaOqaauaabeqaceaaaeaaqaaaaaaaaaWdbmaabmaapaqaa8qacaWGMbWefv3ySLgznfgDOfdaryqr1ngBPrginfgDObYtUvgaiuaacqWFwksicaWGcbaacaGLOaGaayzkaaWaaeWaa8aabaWdbiaad2gaaiaawIcacaGLPaaacqGH9aqppaWaaCbeaeaapeGaciyBaiaacMgacaGGUbaal8aabaWdbiaad6gacqGH9aqpcaaIWaGaaiilaiabgAci8kaac6cacaGGSaGaamytaiabgkHiTiaaigdaa8aabeaak8qacaWGMbWaaeWaa8aabaWdbiaad2gacqGHRaWkcaWGUbaacaGLOaGaayzkaaGaeyOeI0IaamOqamaabmaapaqaa8qacaWGUbaacaGLOaGaayzkaaaapaqaa8qacaWGMbGaam4BaiaadkhacaGGGcGaamOtaiabg6da+iaad2eacaGGGcGaamyyaiaad6gacaWGKbGaaiiOaiaad2gacqGH9aqpcaaIWaGaaiilaiabgAci8kabgAci8kabgAci8kaac6cacaGGUaGaaiilaiaad6eacqGHsislcaWGnbGaaiiOaaaapaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGOaGaae4naiaabMcaaaa@86F2@

The values of ( fΘB ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXafv3ySLgzGmvETj2BSbqefm0B1jxALjhiov2Daebbfv3ySLgzGueE0jxyaibaiKc9yrVq0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadiqacqaaaOqaaabaaaaaaaaapeWaaeWaa8aabaWdbiaadAgacqqHyoqucaWGcbaacaGLOaGaayzkaaaaaa@4125@ are always lower the f.

The dilation of the function F (ECG filtered) by the structuring element B is given by:

( fB )( m )= max n=0,.,M1 f( n )B( mn ) for N>M and m=M1,..,N1            (8) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXafv3ySLgzGmvETj2BSbqefm0B1jxALjhiov2Daebbfv3ySLgzGueE0jxyaibaiKc9yrVq0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadiqacqaaaOqaauaabeqaceaaaeaaqaaaaaaaaaWdbmaabmaapaqaa8qacaWGMbGaeyyLIuSaamOqaaGaayjkaiaawMcaamaabmaapaqaa8qacaWGTbaacaGLOaGaayzkaaGaeyypa0ZdamaaxababaWdbiGac2gacaGGHbGaaiiEaaWcpaqaa8qacaWGUbGaeyypa0JaaGimaiaacYcacqGHMacVcaGGUaGaaiilaiaad2eacqGHsislcaaIXaaapaqabaGcpeGaamOzamaabmaapaqaa8qacaWGUbaacaGLOaGaayzkaaGaeyOeI0IaamOqamaabmaapaqaa8qacaWGTbGaeyOeI0IaamOBaaGaayjkaiaawMcaaaWdaeaapeGaamOzaiaad+gacaWGYbGaaiiOaiaad6eacqGH+aGpcaWGnbGaaiiOaiaadggacaWGUbGaamizaiaacckacaWGTbGaeyypa0JaamytaiabgkHiTiaaigdacaGGSaGaeyOjGWRaeyOjGWRaeyOjGWRaaiOlaiaac6cacaGGSaGaamOtaiabgkHiTiaaigdaaaWdaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeiiaiaabccacaqGGaGaaeikaiaabIdacaqGPaaaaa@7EA5@

The values of ( fB ) MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXafv3ySLgzGmvETj2BSbqefm0B1jxALjhiov2Daebbfv3ySLgzGueE0jxyaibaiKc9yrVq0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadiqacqaaaOqaaabaaaaaaaaapeWaaeWaa8aabaWdbiaadAgacqGHvksXcaWGcbaacaGLOaGaayzkaaaaaa@41B6@ are always higher of f

Erosion and dilation are combined for additional operations.

The opening (o) is defined by the operation of erosion followed by dilation. Closing (•), is defined like a dilation followed by an erosion.

The two operators manipulate the signals in a comparable way. I.e., that the opening removes the peaks positive but preserves the valleys. For the closing of f with the same structuring element (flat) which must be removed all the valleys (peaks negative).

The detection of RR interval can be accomplished that after a good detection of R peak. This detection passes by three stages.

A stage which permit to locate the R peaks positive by the opened operation and another stage which allow to locate the R peaks negative by the application of the closed operation. The final stage to lead to these peaks and of the valleys is the subtraction of ECG signal filtered f with the two preceding operations.

The following formula illustrates the extraction of the R peaks positive:

Peaks (RR) = f – (f o B) (9)

And the following formula illustrates the extraction of the valleys or the R peaks negative:

Valleys (RR) = f – (f • B) (10)

The two preceding formulas are equivalent to:

(Peaks + valleys) (RR)= f – (f o B • B) (11)

The structuring element B is used to detect the peaks and the valleys. In this case is regarded as a geometrical form “segment horizontal various lengths”. The following formula shows the function of the structuring element B:

b( t )={ 1 if | t |<k   0 if not    MathType@MTEF@5@5@+=feaaguart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXafv3ySLgzGmvETj2BSbqefm0B1jxALjhiov2Daebbfv3ySLgzGueE0jxyaibaiKc9yrVq0xXdbba91rFfpec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqaq=JfrVkFHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaaeaabiGaciaacaqabeaadiqacqaaaOqaaabaaaaaaaaapeGaamOyamaabmaapaqaa8qacaWG0baacaGLOaGaayzkaaGaeyypa0Zaaiqaa8aabaqbaeqabiqaaaqaa8qacaaIXaGaaiiOaiaadMgacaWGMbGaaiiOamaaemaapaqaa8qacaWG0baacaGLhWUaayjcSdGaeyipaWJaam4Aaiaacckaa8aabaWdbiaacckacaaIWaGaaiiOaiaadMgacaWGMbGaaiiOaiaad6gacaWGVbGaamiDaiaacckaaaGaaiiOaaGaay5Eaaaaaa@599C@

Where K is constant

One of the problems of the morphological approach to determine the optimal value of K. If it is too small, the transformation will be sensitive to the high frequency noise, and the peaks are incorrectly given. However k which must be lower width of R peaks. The researchers are indicated excellent results by the use of the values between (55-60) ms [16].

Results and Discussions

The morphological approach is evaluated on some reference ECG signals, available from the universal MIT–BIH arrhythmia database [17]. This base contains 48 recordings with a sampling rate of 360 Hz.

For each input ECG signal (filtered), the following procedures were executed:

(i) a pretreatment of ECGs signals; (ii) the signal is operated by the opening for the detection of the peaks positive; (iii) followed by the operation of closing to detect the peaks negative; (iv) after a subtraction enters the filtered signal and the signal detected by opening followed by a closing in order to extract the peaks from QRS complex.

ECG Signal is contaminated by the noises in their recordings in particular the noise of 50-60 Hz and the base line of frequency between 0-1 HZ. The data base is filtered by a five-order pass band Butterworth filter. On figure 2 is respectively illustrated the stages of the QRS complex detection of ECG filtered (recording 100). This figure illustrates the performance of the algorithm: in the detection of RR rate/rhythm. In fact to generate a rate of heart beat RR, the stages of treatment realized and which constitute overall all the stages of morphological filter summarize as follows.

First of all, ECG signal is opened by an element structuring B, which means the application of two operators of morphologies “erosion + dilation”, to locate the peaks positive and to preserve the valleys. This operation “opening”, generates a signal constitute of the valleys (or peaks negative) which are located by the operation of closing “dilation + erosion”. The final stage to lead to the detection of peaks RR is the subtraction of ECG signal filtered with the signal generated by (f o B • B).

The structuring element B is used for the detection of RR peaks. In this case is regarded as a geometrical form “segment horizontal various lengths”. The figure 3a, represents a pathological signal of recording 107. We can notice that the amplitude of the T wave is almost half of R peak. In addition, we used the structuring element with sizes different in the operations morphologies from the opening and closing.

In the figure 3b, the size of the structuring element is lower 55 ms, which meant bad localization of the peak and valleys in the stage of opening and closing.

The figure 2c, illustrates a good performance of detection rate/rhythm RR by the use of the structuring element B with a variable size between (50-60) ms.

The results which one obtained show that the length of the structuring element in the operation of opening and closing plays a very significant role for the detection of RR peaks.

The application of the proposed method by the operators’ morphologies on the recordings (108-109-119-212), gives very satisfactory results as that is illustrated; in figures 4-7.

The selection of the structuring element is very important to follow the variation of RR wave morphology. The figures 4-7 show a variation of the morphology of each QRS complex cycle and the results present a good detection of the RR peaks.

More than 20000 beats of ECG signals are annotated from the database of arrhythmia MIT-BIH. It is employed to evaluate the detection proposed of the morphological filtering.

In order to quantify the performance of the QRS complex detection of ECG signal by the technique proposed, two parameters are used: the Predictivity (P) and sensitivity (Se).

The sensibility (Se) is defined by the equation according to:

Se = TP / (TP + FN)

And the Positive Predictivity (+P) which is the fraction of detections that are real events and it is defined by,

+P = TP / (TP + FP)

Where FN (False Negatives) denotes the number of missed detections, FP (False Positives) represents the number of extra detections and TP (True Positives) is the number of the correctly detected QRS complexes.

The proposed method is compared with Christov’s method [18], Zero Crossing Counts Method (ZCCM) [19], and the Empirical Mode Decomposition (EMD) [2] as shown in table 1.

The experimental result shows that the proposed method performs better as compared to above four methods and allows a reliable and accurate detection of the QRS complexes.


New algorithm based on the mathematical morphology, named the filtering morphological, which was developed for the QRS complex detection of ECG signal. This algorithm is very robust vis-a-vis to the morphology variations of ECG signal and the speed of calculates.

However, the detection of QRS complex consisted three stages; the first is the positive peak detection used operators morphology (opening) followed by closing to detect the negative peaks. Finally, the subtraction of ECG filtered signal and the signal to detect by the operators of opening and closing in order to extract RR peaks. In addition, the structuring element is the key of this detection to extract the shape information from ECG signal. All ECGs from the MIT/BIH database have year evaluation set, show that more interesting performances compared to “Christov’ S”, Zero Crossing Counts Method and Empirical Mode Decomposition method, are obtained.

  1. Goldberger AL, Bhargava V (1982) QRS duration measurement using high-frequency electrocardiography: applications and limitations of a new technique. Comput.Biomed Res 15: 474-484. Link:
  2. Taouli SA, Bereksi-Reguig F (1965) Detection of QRS Complexes in ECG Signals Based on Empirical Mode Decomposition. Global Journal of Computer Science and Technology 11: Version 1.0. Link:
  3. Hamilton PS, Tompkins WJ (1996) Quantitative investigation of QRS detection rules using the MIT-BIH arrhythmia database, IEEE Transactions on Biomedical Engineering. BME 33: 1157-1165. Link:
  4. Hadj Slimane ze (2006) Analyze and synthesis of methods of QRS detection detection of signal ECG. Thesis of doctorate. University Aboubekr Belkaid Tlemcen, ALGERIE, 2006.
  5. Laguna P, Jané R, Caminal P (1994) Automatic detection of wave boundaries in multilead ECG signals: validation with the CSE database. Comput Biomed Res 27: 45-60. Link:
  6. Li C, Zheng C, Tai C (1995) Detection of ECG characteristic points using wavelet Transforms. IEEE Transactions on Biomedical Engineering 42: 21-29. Link:
  7. Daskalov IK, Christov II (1999) Electrocardiogram signal reprocessing for automatic detection of QRS boundaries. Med Eng Phys 21: 37-44. Link:
  8. Mallat S, Zhong S (1992) Characterization of signals from multiscale edges. IEEE Transactions Pattern Analysis and Machine Intelligence 14: 710-732. Link:
  9. Trahanias PE (1993) An approach to QRS complex detection using mathematical morphology. IEEE Trans Biomed Eng 40: 201-205. Link:
  10. Sun Y, Chan K, Krishnan SM (2002) ECG signal conditioning by morphological filtering. Comput Biol Med 32: 465-479. Link:
  11. Sun Y, Chan KL, Krishnan SM (2005) Characteristic wave detection in ECG signal using morphological transform. BMC Cardiovasc Disord 5: 28. Link:
  12. Maragos P (2000) Morphological Signal and Image Processing. CRC Press LLC. Link:
  13. Taouli SA, Reguig FB (2006) Application of the operator’s morphology for the waves detection of the ECG signal. International conference on Electrical Engineering ICEE, Oran, Algeria 06 28-29.
  14. Serra J, Vincent L (1998) Analysis and Mathematical Morphology. II: Theoretical Advances. London: Academic Press.
  15. Serra J, Vincent L (1992) An overview of morphological filtering. Circuits, Systems and Signal Processing 11: 47–108. Link:
  16. Köhler BU1, Hennig C, Orglmeister R (2002) The Principles of Software QRS Detection. IEEE Eng Med Biol Mag 21: 42-57. Link:
  17. MIT–BIH Arrhythmia Database Directory. (1992) Harvard University Massachusetts Institute of Technology, Division of Health Sciences and Technology.
  18. Christov II (2004) Real time electrocardiogram QRS detection using combined adaptive threshold. Biomed Eng Online 3:28. Link:
  19. Köhler BU, Hennig C, Orglmeister R (2003) QRS detection using zero crossing counts. Progress in Biomedical Research 8: 138-145. Link:
© 2019 Taouli SA, et al. This is an open-access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.