2
$\begingroup$

I'm just learning about Fourier Transforms and as an input I'm using a WAV file (Matlab) and taking one channel of it and performing a quick Fourier transform. I've zero padded the input, as I've been told that it gives a better frequency resolution. I've done this and I see an identical looking graph apart from that the magnitude has changed. Could somebody please explain to me why the magnitude has decreased and is their any linearity to how it changes?

I assume that the frequencies will be similar to those before the zero padding but just be a better fit?

$\endgroup$
4
  • 3
    $\begingroup$ The observed magnitude will depend upon the scaling used by the DFT implementation that you're using. The scaling factor for a forward DFT is arbitrarily chosen by the author of the implementation. It sounds like there could be a factor of $\frac{1}{N}$ or $\frac{1}{\sqrt{N}}$ in your DFT implementation. Since for the zero-padded case, $N$ is larger, but all the extra samples are zero, this will result in a reduction in magnitude on each output. $\endgroup$
    – Jason R
    Commented Mar 12, 2013 at 17:06
  • 5
    $\begingroup$ The notion that zero-padding the input improves the frequency resolution is widely believed but is unfortunately false, or at least not the complete story. Yes, frequency resolution increases, but the frequencies that you get are not of the signal that you want, but of a different signal. $\endgroup$ Commented Mar 12, 2013 at 20:14
  • 3
    $\begingroup$ "I've zero padded the input as I've been told that it gives a better frequency resolution." No. Using a longer chunk of the input gives better frequency resolution. $\endgroup$
    – endolith
    Commented Mar 12, 2013 at 20:54
  • 2
    $\begingroup$ @endolith +1 for that comment. In fact, using a longer chunk of the data gives better frequency resolution of the signal of interest rather than of a signal that abruptly ends when the zero-padding starts. $\endgroup$ Commented Mar 12, 2013 at 22:57

3 Answers 3

3
$\begingroup$

Zero padding is a useful interpolation tool using sinc function (or kernel). I will below explain it in 3 parts. First: what is DFT; Second: Zero-padding; Third: Usage of zero-padding.

(a) $\textbf{What is DFT}$: By taking a DFT of a data set we are mapping the data values from the current discrete domain (many case happens to be time example in audio signals; it can also be spatial co-ordinates as for images) to a discrete frequency domain. With the transform doing this mapping being a matrix (hence linear) which is always full-rank the mapping is always invertible without any loss in information content. Example we can take idft of the obatined dft and get back the same data we started with again or no loss!

Why go to this other domain (so called transform (here frequency) domain) of representing the same data? Well, (a real life note) when we are trying to make decisions we want to see the facts clear in front of us. We don't want unnecessary facts and likes and dislikes to wander in our mind. It similar in signal processing. When we want to analyze data we want to see the data in such a domain of representation where we have,

  • concentration of information only in localized points in that domain
  • the domain gives some sort of a physical interpretation to the data we have (this is a super plus point)

Thus it is clear by using DFT we want see if we can gain from the above two. Of course, if the data has one of the columns of the DFT matrix itself we have gained the maximum out of the DFT domain based representation i.e only one point in the mapped domain values will have a non-zero value ideally. Now suppose the signal is not representable using any one of the columns of the DFT matrix. Then DFT will try to represent the data by a minimal number of mixture of the columns of the DFT matrix i.e only few of the mapped domain values will have a non-zero values. So, which type of data will do this: those which share some characteristics with the DFT matrix columns such as are periodic. $A\ moral$: hence DFT is good to represent periodic data as it gives a minimal representation based on number of non-zeros values (magnitude captures the contribution of each column in making up the original domain data).

(b)$\textbf{ Zero-padding}$: In zero-padding we have first padded zeros to the data in the original domain and then take the new zero-padded signal's DFT. This means by zero-padding we have increased the number of columns in the DFT matrix (with the matrix now also being orthogonal) with no new data in the original domain being added. With this we can hope to see more in deep how much the new added columns contribute in representing the time-domain signal. Note what we earlier say with N-point DFT will also see the same at those N points in a subsequent 2N-point DFT of the same data. So the peak magnitude will not change. (Considering we are not normalizing the DFT matrix). Now when we take the iDFT normalization factor comes into picture and we have to normalize by 1/2N this time to get the same data back instead of by N in the previous case and not pick only N points in the 2N point data. The zero-padding in time-domain can also be interpreted as sinc interpolation in the DFT domain to get the contribution of the newly introduced columns in the 2N-pont DFT. This needs a separate post of detail description. But you can see it easily by drawing the signal and seeing the zero-padded signal as a multiplication of the original assumed to be 2N length signal with a rectangular window which results in convolution in the frequency domain with a sinc function. It may be clear now that we are not increasing frequency resolution by zero-padding i.e we are not resolving two frequencies close by but we are filling new frequencies between the existing N-point DFT frequencies and finding their contributions for making the signal. Frequency resolution can be increased only by sampling the data more finely or taking new data points which is in our hand only if we are an experimenter.

(c) $\textbf{Applications of zero-padding}$: It is used as a frequency domain interpolation tool for getting the side lobe structure for filters. Also it is used to interpolate (or re-sampling) in time domain by zero-padding in frequency domain. Zero-padding in frequency domain needs care so as to preserve the original phase of the signal.

Hope this post is clear. May have a lot of redundancy if you already know much of it.

$\endgroup$
2
$\begingroup$

This is directly related to a generalization of this previous question and to Parseval's equality. When you expand your spectrum by zero padding, you increase the size of your signal. Since you did not change its total energy (because you only added $0$'s), you did actually divide the amplitude of each sample after inversion of the Fourier transform.

Consider for example the DC coefficient, that is equal to the mean of the input image. After doubling the size of the spectrum along each dimension :$(w,h) \rightarrow (2w,2h)$, and inversion of the Fourier transform, you obtain an image with 4 times more pixels but the same mean. Hence, you did divide the value of each individual sample by 4. The same reasoning goes for each coefficient.

On the other hand, if you apply the correct scaling before inverting the Fourier transform (multiply the amplitude by 2 in your case, by 4 with my image example), you obtain a zoomed signal where the amplitudes are correct.

$\endgroup$
1
$\begingroup$

Zero-padding before an FFT gives you a higher density interpolation, which can increase graphic or plot resolution, but it's only an interpolation, not added information. Any closer spectral peak pairs or finer "wrinkles" in the spectrum won't appear, and you can get almost the same effect by using an appropriate smooth curve-fitting algorithm (such as splines or Sinc kernel interpolation) before graphing the non-zero-padded FFT result.

If your FFT is dividing by N, then feeding it the exact same data but using a larger N denominator (wider FFT aperture after zero-padding), will re-scale the FFT result by the ratio of the two N's. But not all FFT implementations divide by N. Check yours.

$\endgroup$

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.