# Digital filtering

Other languages:
English • ‎español
Series Geophysical References Series Digital Imaging and Deconvolution: The ABCs of Seismic Exploration and Processing Enders A. Robinson and Sven Treitel 5 http://dx.doi.org/10.1190/1.9781560801610 ISBN 9781560801481 SEG Online Store
On such a full sea are we now afloat;
And we must take the current when it serves,
Or lose our ventures.

- William Shakespeare, ''Julius Caesar''

What is digital filtering? The behavior of analog filters ordinarily is studied in the frequency domain. Digital filtering, on the other hand, is treated more fruitfully in the time domain. A digital filter is represented by its impulse response. The impulse response is made up of a sequence of numbers that act as weighting coefficients. The output of a digital filter is obtained by convolving the digitized input signal with the filter’s impulse response.

The mechanics of digital filtering in the time domain can be described with the aid of Z-transform theory. The amplitude spectrum and the phase spectrum represent an important characterization of the filter. A digital filter is said to be causal if its output at time n depends only on its input at time n and on inputs at times before n. In Chapter 6, these ideas are related to the more familiar interpretation of filter behavior in the frequency domain.

What is a causal digital filter? As we just mentioned, a digital filter is represented by a sequence of numbers called its impulse response or its weighting coefficients. A digital filter is causal if its present output (at time n) depends only on present and past inputs (that is, depends only on inputs at times n, n – 1, n – 2, …, and so on). Another term for a causal filter is a realizable filter.

What is a constant digital filter? A constant filter is one that has a single constant weighting coefficient ${\displaystyle b_{0}}$. Such a filter is causal. Its action is shown schematically by the block diagram in Figure 1a, in which the input is on the left and the output is on the right of the rectangular box that indicates the filter.

Let us show that a constant filter scales the input. We can illustrate the action of the constant filter with Table 1 (in which we have let ${\displaystyle b_{0}={0.5}}$). Figure 1b shows the input and the output. The output is the input scaled by the constant coefficient 0.5.

What is a unit-delay digital filter? We introduce the concept of a digital filter that produces a unit delay. Such a digital filter is called the unit-delay filter. Let us represent this filter with the symbol Z. Thus, we have the block diagram shown in Figure 2a. Figure 2b shows the input signal (the original signal) and the output signal (the signal with a delay of one time unit).

Figure 1.  (a) A constant weighting merely scales the output. The variable n is the time index, where ${\displaystyle n\ =\ {0,1,2,3}}$,…. (b) Left: The input is the original signal. Right: The output is the signal scaled by 0.5.
Table 1. A constant filter.
Time index n Input ${\displaystyle x_{n}}$ Output ${\displaystyle y_{n}\ =\ {0.5}\ x_{n}}$
0 10 5
1 20 10
2 10 5
3 10 5
4 –10 –5
5 0 0
Figure 2.  (a) A filter that produces a delay of one time unit. (b) Left: The original signal. Right: The signal delayed by one time unit.

We see that this filter is causal because its output at time n depends only on its input at time n – 1. In terms of the readings, we have

 {\displaystyle {\begin{aligned}y_{1}\;=\;x_{0},\;y_{2}\;=\;x_{1},\;y_{3}\;=\;x_{2},\;\ldots \;.\end{aligned}}} (1)

Table 2 shows the results.

What is the symbol Z? The symbol Z used here has a special mathematical meaning: Z represents an operator that produces a unit delay. Thus, we call Z the unit-delay operator. It follows that ${\displaystyle Z^{-1}}$ represents an operator that produces a unit advance. As we will see, the symbol Z is the variable that defines the Z-transform. Used in this way, Z is a complex variable in the complex Z-plane.

What is a series connection? If we connect two unit-delay filters in series, we have the situation shown in Figure 3a. By a series connection, we mean that the output from filter 1 is the input to filter 2. We see that the resulting overall filter is causal because its output at time n depends only on the input at time n – 2. Now, filter 1 produces a unit delay, so its output is ${\displaystyle x_{n-1}}$. Next we use the fact that the input to filter 2 is the output from filter 1, so the input to filter 2 is ${\displaystyle x_{n-1}}$. Because filter 2 produces a unit delay, its output is ${\displaystyle x_{n-2}}$.

Table 2. A unit-delay filter.
Time index n Input ${\displaystyle x_{n}}$ Output ${\displaystyle y_{n}=x_{n-1}}$
0 10 -
1 20 10
2 10 20
3 0 10
4 –10 0
5 0 –10
6 - 0
Figure 3.  (a) Two filters in series that produce a delay of two time units. (b) Left: The input is the original signal. Right: The output is the signal delayed by two time units.
Table 3. A two-unit-delay filter.
Time index n Input ${\displaystyle x_{n}}$ Output from Filter 1 Input to Filter 2 Output ${\displaystyle y_{n}=x_{n-2}}$
0 10 - - -
1 20 10 10 -
2 10 20 20 10
3 0 10 10 20
4 –10 0 0 10
5 0 –10 –10 0
6 - 0 0 –10
7 - - - 0
Figure 4.  (a) A filter that produces a delay of two time units. (b) A filter that produces a delay of N time units. (c) A filter that produces a zero delay. In other words, the output is the same as the input.

In terms of the readings, we have the results shown in Table 3. Thus, two unit-delay filters in series result in a filter of delay two. Figure 3b shows the input and output signals.

In summary, we see that two unitdelay filters in series are equivalent to a filter with a two-unit delay. That is, if the input is ${\displaystyle x_{n}}$, the output is ${\displaystyle x_{n-2}}$. Thus, a delay of two units is represented by the mathematical operator ${\displaystyle Z^{2}}$ (i.e., Z to the second power), with the exponent 2 representing the delay (Figure 4a).

What happens when we connect N unit-delay filters in series? By the same reasoning as above, we see that N unit-delay filters in series are equivalent to a filter with an N-unit delay. That is, if the input is ${\displaystyle x_{n}}$, the output is ${\displaystyle x_{n-N}}$. A delay of N units is represented by the mathematical operator ${\displaystyle Z^{N}}$ (i.e., Z to the Nth power), with the exponent N representing the delay (Figure 4b).

What happens when N = 0? Because the exponent represents the delay, we see that in this case, the delay is zero, so input is equal to output (Figure 4c). Thus, the filter ${\displaystyle Z^{0}}$ represents the identity filter, and in keeping with ordinary algebra, we let ${\displaystyle Z^{0}=1}$. We see that the N-unit delay filter is causal for any nonnegative value of N (i.e., for N > 0) because the output at time n depends only on input at time nN. The constant filter ${\displaystyle b_{0}}$ (described previously) can be represented more explicitly by the term ${\displaystyle b_{0}Z^{0}}$.

Now let us connect a constant filter and a unit-delay filter in series. The series (or cascaded) combination of a constant filter ${\displaystyle b_{1}}$ followed by the unit-delay filter Z gives the filter ${\displaystyle b_{1}Z}$, the filter ${\displaystyle b_{1}}$ connected in series with the filter Z is shown in Figure 5a. We see that this filter is causal because its output at time n depends on its input at time n – 1. We can illustrate the action of the filter by Table 4 (in which we have let ${\displaystyle b_{1}=0.25}$) as well as by Figure 5b.

Next we connect a unit-delay filter and a constant filter in series. We notice that the weighting coefficient ${\displaystyle b_{1}}$ is associated with the unit-delay filter. It is evident that the series combination of the Z filter followed by the ${\displaystyle b_{1}}$ filter gives the filter ${\displaystyle Zb_{1}}$ (Figure 5c). We can illustrate the action of the filter by Table 5 (in which we have let ${\displaystyle b_{1}=0.25}$). Hence, we see that the filter ${\displaystyle b_{1}Z}$ is equivalent to the filter ${\displaystyle Zb_{1}}$.

Figure 5.  (a) A filter that produces a multiplication and a delay. (b) Left: The input is the original signal. Right: The output is the signal scaled by one-quarter and then delayed by one time unit. (c) A filter that produces a delay and a multiplication.
Table 4. A scaled unit-delay filter.
Time index n Input ${\displaystyle x_{n}}$ ${\displaystyle b_{1}\ x_{n}}$ Output ${\displaystyle y_{n}=b_{1}x_{n-1}}$
0 10 2.5 -
1 20 5.0 2.5
2 10 2.5 5.0
3 0 0.0 2.5
4 –10 –2.5 0.0
5 0 0.0 –2.5
6 - - 0.0
Table 5. An alternate form of a scaled unit-delay filter.
Time index n Input ${\displaystyle x_{n}}$ ${\displaystyle x_{n-1}}$ Output ${\displaystyle y_{n}=x_{n-1}b_{1}}$
0 10 - -
1 20 10 2.5
2 10 20 5.0
3 0 10 2.5
4 –10 0 0.0
5 0 –10 –2.5
6 - 0 0.0
Figure 6.  (a) The parallel connecting element. (b) The combination of two filters in parallel. (c) The combination of two signals by a mixer.

What is a parallel connection and what is a mixer? Up to this point, we have connected two digital filters in series. Now we wish to introduce a parallel connection. Such a connection will be illustrated in our block diagrams by the connecting element, as shown in Figure 6a. This figure illustrates that a parallel connecting element, when taken by itself, yields the same output on each line of a fork. The combination of the filter ${\displaystyle b_{0}}$ and the filter ${\displaystyle b_{1}Z}$ connected in parallel to the same input ${\displaystyle x_{n}}$ would yield the block diagram shown in Figure 6b. A mixer is a device that adds (or subtracts) two inputs to yield an output. The circle in Figure 6c shows an example of such a device.

Let us diagram a two-term digital filter. The block diagram of Figure 7a depicts the filter given by ${\displaystyle b_{0}+b_{1}Z}$. We see that this filter is causal because its output at time n depends only on its input at times n and n – 1. The output of the subcomponent ${\displaystyle b_{0}}$ is ${\displaystyle b_{0}x_{n}}$. The output of the subcomponent ${\displaystyle b_{1}Z}$ is ${\displaystyle b_{1}x_{n-1}}$. These two outputs then are fed as inputs into the mixer, which adds them and produces the output ${\displaystyle y_{n}=b_{0}x_{n}+b_{1}x_{n-1}}$. Let us illustrate numerically the action of this filter for ${\displaystyle b_{0}=0.5}$ and ${\displaystyle b_{1}=0.25}$ so that our filter is 0.5 + 0.25 Z (Figure 7b and Table 6). The block diagram shown in Figure 7c depicts another representation of the same two-term causal filter ${\displaystyle b_{0}+b_{1}\ Z}$.

What happens if we connect a constant filter and a unit-delay filter in series? As we have seen, the series connection of two unit-delay filters is equivalent to a filter with a two-unit delay. We recall that ${\displaystyle Z^{N}}$ represents an N-unit delay filter. A constant filter ${\displaystyle b_{N}}$ connected in series with the N-unit delay filter ${\displaystyle Z^{N}}$ yields the filter ${\displaystyle b_{N}Z^{N}}$, shown by Figure 8a. For example, suppose that N = 2 and ${\displaystyle b_{2}=0.75}$. Then the filter ${\displaystyle b_{2}\ Z^{2}}$ (Figure 8b) is illustrated by Table 7.

Figure 7.  (a) The filter with impulse-response function ${\displaystyle \left\{b_{0},\ b_{1}\right\}}$. The term feedforward comes from the fact that the arrows for the loops point in the forward direction. (b) Left: The original signal. Right: The signal filtered by the impulse-response function ${\displaystyle \left\{b_{0},\ b_{1}\right\}=\{0.5,0.25\}}$. (c) Another configuration of the filter with impulse-response function ${\displaystyle \left\{b_{0},\ b_{1}\right\}}$.
Table 6. A two-coefficient filter.
Time index n Input ${\displaystyle x_{n}}$ ${\displaystyle b_{0}\ x_{n}}$ ${\displaystyle x_{n-1}}$ ${\displaystyle b_{1}x_{n-1}}$ Output ${\displaystyle y_{n}=b_{0}x_{n}+b_{1}x_{n-1}}$
0 10 5 - - 5.0
1 20 10 10 2.5 12.5
2 10 5 20 5.0 10.0
3 0 0 10 2.5 2.5
4 –10 –5 0 0.0 –5.0
5 0 0 –10 –2.5 –2.5
6 - - 0 0.0 0.0

The most general causal filter with a finite number of delay elements has the form

 {\displaystyle {\begin{aligned}b_{0}+b_{1}Z+b_{2}Z^{2}+b_{3}Z^{3}+\dots +b_{N}Z^{N}\end{aligned}}} (2)

The set of coefficients ${\displaystyle \left\{b_{0},\ b_{1},\ \ b_{2},\ b_{3},\ b_{N}\right\}}$ makes up the impulse-response function of the filter. For example, the filter ${\displaystyle b_{0}+b_{1}Z+b_{2}Z^{2}}$ has the block diagram shown in Figure 9a. We see that this filter is causal because its output at time n depends only on its input at times n, ${\displaystyle n-1}$, and ${\displaystyle n-2}$. We can illustrate this filter numerically by letting ${\displaystyle b_{0}=0.5,b_{1}=0.25,b_{2}=0.75}$. Thus, the filter (Figure 9b and Table 8) is

 {\displaystyle {\begin{aligned}y_{n}=b_{0}x_{n}+b_{1}x_{n-1}+b_{2}x_{n-2}=0.5x_{n}+0.25x_{n-1}+0.75x_{n-2}.\end{aligned}}} (3)

The Nth-order causal filter ${\displaystyle b_{0}+b_{1}Z+...+b_{N}Z^{N}}$ can be illustrated by the block diagram shown in Figure 10.

Figure 8.  (a) The filter with impulse-response function ${\displaystyle \left\{{0,\ 0,}\dots {0,\ }b_{N}\right\}}$. (b) Left: The original signal. Right: The signal filtered by the impulse-response function ${\displaystyle \left\{b_{0},\ b_{1},\ b_{2}\right\}=\{0,0,0.75\}}$.
Table 7. A scaled two-delay filter.
Time index n Input ${\displaystyle x_{n}}$ ${\displaystyle x_{x-2}}$ Output ${\displaystyle y_{n}=b_{2}x_{n-2}}$
0 10 - -
1 20 - -
2 10 10 7.5
3 0 20 15.0
4 –10 10 7.5
5 0 0 0.0
6 - –10 –7.5
7 - 0 0.0

What is a feedforward filter? In Figure 10, we see that the input is fed forward through the delay boxes and the impulse-response-coefficient boxes to produce the output. As a result, we call a causal filter of this type a causal feedforward filter. The set of weighting coefficients of the causal feedforward filter is also called the impulse-response function or the memory function of the filter. Because the number of coefficients is finite, such a filter is often called a causal finite impulse-response filter, or simply a causal FIR filter, where FIR is an acronym.

Figure 9.  (a) The filter with impulse-response function ${\displaystyle \left\{b_{0},\ b_{1},\ b_{2}\right\}}$. (b) Left: The input is the original signal. Right: The output is the signal filtered by the impulse-response function ${\displaystyle \left\{b_{0},\ b_{1},\ b_{2}\right\}=\{{0.5},0.25,0.75\}}$.
Table 8. A three-coefficient filter.
Time index n Input ${\displaystyle x_{n}}$ ${\displaystyle b_{0}x_{n}}$ ${\displaystyle b_{1}x_{n-1}}$ ${\displaystyle b_{2}x_{n-2}}$ Output ${\displaystyle y_{n}=\sum _{i{=0}}^{2}{b_{i}}x_{n-i}}$
0 10 5 - - 5.0
1 20 10 2.5 - 12.5
2 10 5 5.0 7.5 17.5
3 0 0 2.5 15.0 17.5
4 –10 –5 0.0 7.5 2.5
5 0 0 –2.5 0.0 –2.5
6 - - 0.0 –7.5 –7.5
7 - - - 0.0 0.0
Figure 10.  The filter with impulse-response function ${\displaystyle \{b_{0},\;b_{1},...,\;b_{N}\}}$.

Now we shall explain the reason for the term impulse-response function. Let ${\displaystyle \{b_{0},b_{1}}$ ${\displaystyle b_{2},b_{3},\ldots ,b_{N}\}}$ be the impulse-response function of a filter. Let the input to the filter be the Kronecker delta function, or unit-impulse function, given by

 {\displaystyle {\begin{aligned}\delta =\left\{{1,\ 0,\ 0,\ }\cdots \right\},\end{aligned}}} (4)

where the 1 occurs at time 0. Then, from Figure 10, we see that the output of the filter is

 {\displaystyle {\begin{aligned}y=\left\{{{b_{0}},\;{b_{1}},\;{b_{2}},\;{b_{3}},\;.\;.\;.\;,\;{b_{N}}}\right\}.\end{aligned}}} (5)

Thus, the impulse-response function is the response of a filter to a unit impulse. The impulse-response function is also called the transfer function in the time domain.