Zero Padding Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search


Zero Padding

Zero padding consists of extending a signal (or spectrum) with zeros to extend its time (or frequency band) limits. It maps a length $ N$ signal to a length $ M>N$ signal, but $ M$ need not be an integer multiple of $ N$. To unify the time-domain and frequency-domain definitions of zero-padding, it is necessary to regard the original time axis $ [0,1,\dots,N-1]$ as indexing positive-time samples from 0 to $ N/2-1$ (for $ N$ even), and negative times in the interval $ n\in[N-N/2+1,N-1]\equiv[-N/2+1,-1]$. Furthermore, we require $ x(N/2)\equiv x(-N/2)=0$ when $ N$ is even, while odd $ N$ requires no such restriction.



Definition:

$\displaystyle \hbox{\sc ZeroPad}_{M,m}(x) \isdef \left\{\begin{array}{ll} x(m),...
...ert m\vert < N/2 \\ [5pt] 0, & \mbox{otherwise} \\ \end{array} \right. \protect$ (7.4)

where $ m=0,\pm1,\pm2,\dots,\pm M_h$, with $ M_h\isdef (M-1)/2$ for $ M$ odd, and $ M/2 - 1$ for $ M$ even. For example,

$\displaystyle \hbox{\sc ZeroPad}_{10}([1,2,3,4,5]) = [1,2,3,0,0,0,0,0,4,5].
$

In this example, the first sample corresponds to time 0, and five zeros have been inserted between the samples corresponding to times $ n=2$ and $ n=-2$.

Figure 7.7 illustrates zero padding from length $ N=5$ out to length $ M=11$. Note that $ x$ and $ n$ could be replaced by $ X$ and $ k$ in the figure caption.

Figure 7.7: Illustration of zero padding: a) Original signal (or spectrum) $ x=[3,2,1,1,2]$ plotted over the domain $ n\in [0,N-1]$ where $ N=5$ (i.e., as the samples would normally be held in a computer array). b) $ \hbox{\sc ZeroPad}_{11}(x)$. c) The same signal $ x$ plotted over the domain $ n\in [-(N-1)/2, (N-1)/2]$ which is more natural for interpreting negative times (frequencies). d) $ \hbox{\sc ZeroPad}_{11}(x)$ plotted over the zero-centered domain.
\includegraphics[width=\textwidth]{eps/zpad}

When a signal $ x(n)$ is causal, that is, $ x(n)=0$ for all negative-time samples ( $ n=-1,-2,\dots,-N/2$), then zero-padding can be carried out by simply appending zeros to the original signal. For example,

$\displaystyle \hbox{\sc ZeroPad}_{10}([1,2,3,4,5]) = [1,2,3,4,5,0,0,0,0,0]$   (causal case)$\displaystyle . \protect$

The causal definition is natural when $ x(n)$ represents a signal starting at time 0 and extending for $ N$ samples. On the other hand, when we are zero-padding a spectrum, or we have a time-domain signal including both positive- and negative-time samples, then the zeros should be inserted ``outside the nonzero interval'' of the signal or spectrum, as defined in Eq. (7.4).


Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work] [Order a printed hardcopy]

``Mathematics of the Discrete Fourier Transform (DFT), with Music and Audio Applications'', by Julius O. Smith III, W3K Publishing, 2003, ISBN 0-9745607-0-7.
Copyright © 2007-02-02 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA  [Automatic-links disclaimer]