(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.

enter image description here

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:

enter image description here

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:

enter image description here

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...
  • $\begingroup$ 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. $\endgroup$
    – Jason R
    Commented Dec 1, 2011 at 22:05
  • $\begingroup$ Sorry, my bad for posting misleading screenshots. I have included close-ups of sample damaged sections. $\endgroup$
    – P i
    Commented Dec 1, 2011 at 23:18
  • $\begingroup$ A lowpass filter should work. The problem is that the frequencies of interest are changing as the person changes their swipe speed. $\endgroup$
    – endolith
    Commented Dec 2, 2011 at 15:14
  • $\begingroup$ 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... $\endgroup$
    – P i
    Commented Dec 4, 2011 at 0:57
  • 2
    $\begingroup$ 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. $\endgroup$
    – mbaitoff
    Commented Jan 9, 2012 at 8:08

1 Answer 1


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").


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.