# Removing noise from F2F signal

(This question relates to Extracting Binary Magnetic-Strip Card Data from raw WAV)

I am extracting the binary sequence from the magnetic strip on a credit card.

As you can see, the signal is degraded clearly in one place. also there is a minor degradation right on the left of the image.

Just using IIR (i.e. $X_{\rm out} = 0.9X_{\rm out_{last}} + 0.1X_{\rm in}$) smooths it, but the resulting signal is not mathematically smooth; if I differentiate the signal a couple of times the noise comes back with a vengeance:

My question is: can I remove the noise in such a way that the derivatives come out clean?

If so, how?

EDIT: Here is a close-up of some damaged waves:

EDIT(2): A couple of approaches I am considering:

• Firstly I could make a taylor approximation of the signal either side of the damaged sector, and blend the approximations together.
• Secondly I could FFT, remove high-frequency components and reverse FFT. I'm going to try that second approach now...
• You're using a differentiator to pluck out high-frequency features in the signal (i.e. sharp transitions). The artifacts that you're trying to remove are similar, in that they are sharp transitions that will have similar highpass characteristics. They could be difficult to remove with a linear lowpass filter. A different approach (no pun intended) might be more appropriate. – Jason R Dec 1 '11 at 22:05
• Sorry, my bad for posting misleading screenshots. I have included close-ups of sample damaged sections. – P i Dec 1 '11 at 23:18
• A lowpass filter should work. The problem is that the frequencies of interest are changing as the person changes their swipe speed. – endolith Dec 2 '11 at 15:14
• Correct. However, this base rate isn't going to change massively from one wave to the next. So I may be able to filter as I go (ie given the wavelength is k at a particular point, filter ahead in the signal an estimated 2 wavelengths, pick up the next blip, rinse and repeat). In this case, what would be a good filter? I need to preserve the derivatives... – P i Dec 4 '11 at 0:57
• It seems that your signal is represented by the series of very distinctive "wavelets" describing the binary transitions. I think you should extract one distinctive wavelet and produce a "correlogram" by correlating the wavelet with the raw data. The positions of maximum similarity will be identified as strong peaks, while the waveform flaws will become only a minor noise. This method is widely used in seismic. Would you please provide a "time-value" series of your raw data in some spreadsheet-like form, so I can illustrate my idea. – mbaitoff Jan 9 '12 at 8:08

## 1 Answer

To remove high-frequency "noise" without removing sharp transitions, you might have to try some sort of non-linear filtering process.

A random example might be applying (cross fading to) a median filter only when the distance to the nearest N local maxima (or minima, and beyond some noise threshold) goes under some distance threshold (where this distance, N and the median filter width, are calibrated to the period of the suspected "noise").