Digital Signal Processing. The Scientist and Engineers Guide. Steven W. Smith
.pdf
298 |
The Scientist and Engineer's Guide to Digital Signal Processing |
Besides the desired m a g n i t u d e array shown in (a), there must be a corresponding phase array of the same length. In this example, the phase of the desired frequency response is entirely zero (this array is not shown in Fig. 17-1). Just as with the magnitude array, the phase array can be loaded with any arbitrary curve you would like the filter to produce. However, remember that the first and last samples (i.e., 0 and 512) of the phase array must have a value of zero (or a multiple of 2B, which is the same thing). The frequency response can also be specified in rectangular form by defining the array entries for the real and imaginary parts, instead of using the magnitude and phase.
The next step is to take the Inverse DFT to move the filter into the time domain. The quickest way to do this is to convert the frequency domain to rectangular form, and then use the Inverse FFT. This results in a 1024 sample signal running from 0 to 1023, as shown in (b). This is the impulse response that corresponds to the frequency response we want; however, it is not suitable for use as a filter kernel (more about this shortly). Just as in the last chapter, it needs to be shifted, truncated, and windowed. In this example, we will design the filter kernel with M ' 40 , i.e., 41 points running from sample 0 to sample 40. Table 17-1 shows a computer program that converts the signal in (b) into the filter kernel shown in (c). As with the windowed-sinc filter, the points near the ends of the filter kernel are so small that they appear to be zero when plotted. Don't make the mistake of thinking they can be deleted!
100 |
'CUSTOM FILTER DESIGN |
|
110 |
'This program converts an aliased 1024 point impulse response into an M+1 point |
|
120 |
'filter kernel (such as Fig. 17-1b being converted into Fig. 17-1c) |
|
130 |
' |
|
140 |
DIM REX[1023] |
'REX[ ] holds the signal being converted |
150 |
DIM T[1023] |
'T[ ] is a temporary storage buffer |
160 |
' |
|
170 |
PI = 3.14159265 |
|
180 |
M% = 40 |
'Set filter kernel length (41 total points) |
190 |
' |
|
200 |
GOSUB XXXX |
'Mythical subroutine to load REX[ ] with impulse response |
210 |
' |
|
220 |
FOR I% = 0 TO 1023 'Shift (rotate) the signal M/2 points to the right |
|
230 |
INDEX% = I% + M%/2 |
|
240 |
IF INDEX% > 1023 THEN INDEX% = INDEX%-1024 |
|
250 |
T[INDEX%] = REX[I%] |
|
260 NEXT I% |
|
|
270 |
' |
|
280 FOR I% = 0 TO 1023 |
|
|
290 |
REX[I%] = T[I%] |
|
300 NEXT I% |
|
|
310 |
' |
'Truncate and window the signal |
320 FOR I% = 0 TO 1023 |
|
|
330 |
IF I% <= M% THEN REX[I%] = REX[I%] * (0.54 - 0.46 * COS(2*PI*I%/M%)) |
|
340 |
IF I% > M% THEN REX[I%] = 0 |
|
350 NEXT I% |
|
|
360 |
' |
'The filter kernel now resides in REX[0] to REX[40] |
370 END |
TABLE 17-1 |
|
|
|
|
300 |
The Scientist and Engineer's Guide to Digital Signal Processing |
When designing a custom filter, the desired frequency response is defined by the values in an array. Now consider this: what does the frequency response do between the specified points? For simplicity, two cases can be imagined, one "good" and one "bad." In the "good" case, the frequency response is a smooth curve between the defined samples. In the "bad" case, there are wild fluctuations between. As luck would have it, the impulse response in (b) corresponds to the "bad" frequency response. This can be shown by padding it with a large number of zeros, and then taking the DFT. The frequency response obtained by this method will show the erratic behavior between the originally defined samples, and look just awful.
To understand this, imagine that we force the frequency response to be what we want by defining it at an infinite number of points between 0 and 0.5. That is, we create a continuous curve. The inverse DTFT is then used to find the impulse response, which will be infinite in length. In other words, the "good" frequency response corresponds to something that cannot be represented in a computer, an infinitely long impulse response. When we represent the frequency spectrum with N/2 % 1 samples, only N points are provided in the time domain, making it unable to correctly contain the signal. The result is that the infinitely long impulse response wraps up (aliases) into the N points. When this aliasing occurs, the frequency response changes from "good" to "bad." Fortunately, windowing the N point impulse response greatly reduces this aliasing, providing a smooth curve between the frequency domain samples.
Designing a digital filter to produce a given frequency response is quite simple. The hard part is finding what frequency response to use. Let's look at some strategies used in DSP to design custom filters.
Deconvolution
Unwanted convolution is an inherent problem in transferring analog information. For instance, all of the following can be modeled as a convolution: image blurring in a shaky camera, echoes in long distance telephone calls, the finite bandwidth of analog sensors and electronics, etc. Deconvolution is the process of filtering a signal to compensate for an undesired convolution. The goal of deconvolution is to recreate the signal as it existed before the convolution took place. This usually requires the characteristics of the convolution (i.e., the impulse or frequency response) to be known. This can be distinguished from blind deconvolution, where the characteristics of the parasitic convolution are not known. Blind deconvolution is a much more difficult problem that has no general solution, and the approach must be tailored to the particular application.
Deconvolution is nearly impossible to understand in the time domain, but quite straightforward in the frequency domain. Each sinusoid that composes the original signal can be changed in amplitude and/or phase as it passes through the undesired convolution. To extract the original signal, the deconvolution filter must undo these amplitude and phase changes. For
302 |
The Scientist and Engineer's Guide to Digital Signal Processing |
Energy |
Voltage |
Time |
Time |
scintillator
gamma ray 



























amplifier
light |
light detector |
|
FIGURE 17-3
Example of an unavoidable convolution. A gamma ray detector can be formed by mounting a scintillator on a light detector. When a gamma ray strikes the scintillator, its energy is converted into a pulse of light. This pulse of light is then converted into an electronic signal by the light detector. The gamma ray is an impulse, while the output of the detector (i.e., the impulse response) resembles a one-sided exponential.
is then converted into an electronic signal by a light detector, such as a photodiode or photomultiplier tube. Each pulse produced by the detector resembles a one-sided exponential, with some rounding of the corners. This shape is determined by the characteristics of the scintillator used. When a gamma ray deposits its energy into the scintillator, nearby atoms are excited to a higher energy level. These atoms randomly deexcite, each producing a single photon of visible light. The net result is a light pulse whose amplitude decays over a few hundred nanoseconds (for sodium iodide). Since the arrival of each gamma ray is an impulse, the output pulse from the detector (i.e., the one-sided exponential) is the impulse response of the system.
Figure 17-4a shows pulses generated by the detector in response to randomly arriving gamma rays. The information we would like to extract from this output signal is the amplitude of each pulse, which is proportional to the energy of the gamma ray that generated it. This is useful information because the energy can tell interesting things about where the gamma ray has been. For example, it may provide medical information on a patient, tell the age of a distant galaxy, detect a bomb in airline luggage, etc.
Everything would be fine if only an occasional gamma ray were detected, but this is usually not the case. As shown in (a), two or more pulses may overlap, shifting the measured amplitude. One answer to this problem is to deconvolve the detector's output signal, making the pulses narrower so that less pile-up occurs. Ideally, we would like each pulse to resemble the original impulse. As you may suspect, this isn't possible and we must settle for a pulse that is finite in length, but significantly shorter than the detected pulse. This goal is illustrated in Fig. 17-4b.
304 |
The Scientist and Engineer's Guide to Digital Signal Processing |
example means trying to make the desired pulse excessively narrow. Let's look at what happens. If the desired pulse is made narrower, its frequency spectrum must contain more high frequency components. Since these high frequency components are at a very low amplitude in the detected pulse, the filter must have a very high gain at these frequencies. For instance, (f) shows that some frequencies must be multiplied by a factor of three to achieve the desired pulse in (c). If the desired pulse is made narrower, the gain of the deconvolution filter will be even greater at high frequencies.
The problem is, small errors are very unforgiving in this situation. For instance, if some frequency is amplified by 30, when only 28 is required, the deconvolved signal will probably be a mess. When the deconvolution is pushed to greater levels of performance, the characteristics of the unwanted convolution must be understood with greater accuracy and precision. There are always unknowns in real world applications, caused by such villains as: electronic noise, temperature drift, variation between devices, etc. These unknowns set a limit on how well deconvolution will work.
Even if the unwanted convolution is perfectly understood, there is still a factor that limits the performance of deconvolution: noise. For instance, most unwanted convolutions take the form of a low-pass filter, reducing the amplitude of the high frequency components in the signal. Deconvolution corrects this by amplifying these frequencies. However, if the amplitude of these components falls below the inherent noise of the system, the information contained in these frequencies is lost. No amount of signal processing can retrieve it. It's gone forever. Adios! Goodbye! Sayonara! Trying to reclaim this data will only amplify the noise. As an extreme case, the amplitude of some frequencies may be completely reduced to zero. This not only obliterates the information, it will try to make the deconvolution filter have infinite gain at these frequencies. The solution: design a less aggressive deconvolution filter and/or place limits on how much gain is allowed at any of the frequencies.
How far can you go? How greedy is too greedy? This depends totally on the problem you are attacking. If the signal is well behaved and has low noise, a significant improvement can probably be made (think a factor of 5-10). If the signal changes over time, isn't especially well understood, or is noisy, you won't do nearly as well (think a factor of 1-2). Successful deconvolution involves a great deal of testing. If it works at some level, try going farther; you will know when it falls apart. No amount of theoretical work will allow you to bypass this iterative process.
Deconvolution can also be applied to frequency domain encoded signals. A classic example is the restoration of old recordings of the famous opera singer, Enrico Caruso (1873-1921). These recordings were made with very primitive equipment by modern standards. The most significant problem is the resonances of the long tubular recording horn used to gather the sound. Whenever the singer happens to hit one of these resonance frequencies, the loudness of the recording abruptly increases. Digital deconvolution has improved the subjective quality of these recordings by






















































































































































































































































Gamma ray strikes















0 10 20 30 40 50


