# Introduction to DSP - filtering: in the frequency domain

 Filtering can be done directly in the frequency domain, by operating on the signal's frequency spectrum: The diagram shows how how a noisy sine wave can be cleaned up by operating directly upon its frequency spectrum to select only a range of frequencies that include signal frequency components but exclude much of the noise: the noisy sine wave (shown as a time signal) contains narrow band signal plus broad band noise the frequency spectrum is calculated the frequency spectrumis modified by suppressing a range outside the signal's frequency components the time domain signal is calculated from the frequency spectrum the resulting signal (shown in the time domain again) looks much cleaner Filtering in the frequency domain is efficient, because every calculated sample of the filtered signal takes account of all the input samples. Filtering in the frequency domain is sometimes called 'acausal'filtering because (at first sight) it violates the laws of cause and effect. Because the frequency spectrum contains information about the whole of the signal - for all time values - samples early in the output take account of input values that are late in the signal, and so can be thought of as still to happen. The frequency domain filter 'looks ahead' to see what the signal is going to do, and so violates the laws of cause and effect. Of course this is nonsense - all it means is we delayed a little until the whole signal had been received before starting the filter calculation - so filtering directly in the frequency domain is perfectly permissible and in fact often the best method. It is often used in image processing. There are good reasons why we might not be able to filter in the frequency domain: we might not be able to afford to wait for future samples - often, we need to deliver the next output as quickly as possible, usually before the next input is received we might not have enough computational power to calculate the Fourier transform we might have to calculate on a continuous stream of samples without the luxury of being able to chop the signal into convenient lumps for the Fourier transform we might not be able to join the edges of the signals smoothly after transforming back from the frequency domain None of the above reasons should make us ignore the possibility of frequency domain filtering, which is very often the best method. It is often used in image processing, or certain types of experiment where the data necessarily comes in bursts, such as NMR or infra red spectroscopy.