In this work we propose a novel approach for filtering noise-affected electrocardiogram (ECG) signals. The proposed method, mainly based on signal approximation by means of linear segments, has been applied for R-peaks recognition and has been compared with both cardiologists' manual marking and the automatic Laguna's method. The obtained results show that when compared to the Laguna's method the proposed algorithm provides a smaller mean error and a better error distribution.