# Cleaning a signal and computing period

I am working with a signal which is a periodic square signal with some kind of noise and some outliers. I would like to know which is the best solution in order to get the period and clean the outliers that can be seen in the image:

The final goal is to binarize the signal.

-
You should not ask the same question on two different stackexchanges. Please contact the moderators (click on the link marked flag at the bottom of your post) and ask them to migrate this question to dsp.SE which is a better fit. – Dilip Sarwate Feb 19 '13 at 14:11

2. Once you lowpass filter the original signal, it won't look like a square wave anymore. The infinitely sharp transitions will be damped. Thus, apply a $1$-bit quantizer (with hysteresis) to the output of the lowpass filter, so that you "binarize" the lowpass filtered signal.