Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
литература / Digital_Video_and_HD_Second_Edition_Algorithms_and_Interfaces.pdf
Скачиваний:
0
Добавлен:
13.05.2026
Размер:
38.02 Mб
Скачать

0

1

t

0

1

t

0

1

t

0 2π ω

0 2π ω

0 2π ω

Figure 20.10 Waveforms of three temporal extents are shown on the left; the corresponding transforms are shown on the right. Spectral width is inversely proportional to temporal extent, not only for the Gaussians shown here, but for all waveforms.

0.4

 

 

 

 

 

 

 

 

 

 

 

 

1 -

x2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0.2

 

 

 

 

 

 

 

P(x)=

 

2

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

1

2

3

 

 

 

 

Figure 20.9 A Gaussian function is shown here in its onesided form, with the scaling that is usual in statistics, where the function (augmented with mean and variance terms) is known as the normal function. Its integral is the error function, erf(x). The frequency response of cascaded Gaussian filters is Gaussian.

Fourier transform pairs

A Gaussian function – graphed in Figure 20.9 in the margin – is the identity function for the Fourier transform: It has the unique property of transforming to itself (within a scale factor). The Gaussian function has moderate spread both in the time domain and in the frequency domain; it has infinite extent, but becomes negligibly small more than a few units from the origin. The Gaussian function lies at the balance point between the distribution of power in the time domain and the distribution of power in the frequency domain.

Functions having short time durations transform to functions with widely distributed frequency components. Conversely, functions that are compact in their frequency representation transform to temporal functions with long duration. See Figure 20.10 above.

Figure 20.11 opposite shows Fourier transform pairs for several different functions. In the left column is a set of waveforms, with the Gaussian in the middle row; in the right column are the corresponding frequency spectra.

200

DIGITAL VIDEO AND HD ALGORITHMS AND INTERFACES

Impulse

(point sampling)

0

1

t

sinc

0

1

t

sinc2

0

1

t

Gaussian

0

1

t

 

 

Triangle (“tent,”

 

 

linear interpolation)

0

1

t

Box

(nearest neighbor)

0

1

t

Constant

0

1

t

Constant

0 2π ω

Box

0 2π ω

 

Triangle

 

0

ω

Gaussian

0 2π ω

sinc2

0 2π ω

sinc

0 2π ω

Impulse

0 2π ω

Figure 20.11 Fourier transform pairs for several functions are shown in these graphs. In the left column is a set of waveforms in the time domain; beside each waveform is its frequency spectrum.

CHAPTER 20

FILTERING AND SAMPLING

201

Averaging neighboring samples is the simplest form of moving average (MA) filter.

Analog filters

Analog filtering is necessary prior to digitization, to bring a signal into the digital domain without aliases. I have described filtering as integration using different weighting functions; an antialiasing filter performs the integration using analog circuitry.

An analog filter performs integration by storing a magnetic field in an inductor (coil) using the elec-

trical property of inductance (L), and/or by storing an electrical charge in a capacitor using the electrical property of capacitance (C). In low-performance filters, resistance (R) is used as well. An ordinary analog filter has an impulse response that is infinite in temporal extent. The design of analog filters is best left to specialists.

Digital filters

Once digitized, a signal can be filtered directly in the digital domain. Design and implementation of such filters – in hardware, firmware, or software – is the domain of digital signal processing (DSP). Filters like the ones that I have been describing are implemented digitally by computing weighted sums of samples.

Perhaps the simplest digital filter is one that just sums adjacent samples; the weights in this case are [1, 1]. Figure 20.12 on the facing page shows the frequency response of such a [1, 1] filter. This filter offers minimal attenuation to very low frequencies; as signal frequency approaches half the sampling rate, the response follows a cosine curve to zero. This is a very simple, very cheap lowpass filter (LPF).

I have drawn in grey the filter’s response from 0.5fS to the sampling frequency. In a digital filter, frequencies in this region are indistinguishable from frequencies between 0.5fS and 0. The gain of this filter at zero frequency (DC) is 2, the sum of its coefficients.

Normally, the coefficients of such a filter are normalized to sum to unity, so that the overall DC gain of the filter is one. In this case the normalized coefficients would be [12, 12]. However, it is inconvenient to call this a [12, 12]-filter; colloquially, this is a [1, 1]-filter. Digital filters can be implemented in software, firm-

ware, or hardware. At the right side of each graph above, I show the block diagrams familiar to hardware

202

DIGITAL VIDEO AND HD ALGORITHMS AND INTERFACES

Figure 20.12 A [1, 1] FIR filter sums two adjacent samples; this forms a simple lowpass filter. I’ll introduce the term FIR on page 207.

Figure 20.13 A [1, -1] FIR filter subtracts one sample from the previous sample; this forms a simple highpass filter.

Figure 20.14 A [1, 0, 1] FIR filter averages a sample and the second preceding sample, ignoring the sample in between; this forms

a bandreject (“notch,” or “trap”) filter at 0.25 fS.

Figure 20.15 A [1, 0, -1] FIR filter subtracts one sample from the second previous sample, ignoring the sample in between; this forms a bandpass filter centered at 0.25 fS.

2

1

0

0

2

1

0

0

2

1

0

0

2

1

0

0

IN

R

 

+1

 

OUT

 

+1

π

Frequency, ω [rad·s-1]

(=1·fS)

IN

R

 

1

 

OUT

 

+1

π

Frequency, ω [rad·s-1]

IN

R

R

 

 

+1

 

 

OUT

 

 

+1

π

 

Frequency, ω [rad·s-1]

 

 

IN

R

R

 

 

1

 

 

OUT

 

 

+1

π

Frequency, ω [rad·s-1]

Subtracting a signal from a lowpass version of itself is equivalent to negating all of coefficients (weights) of the lowpass filter except the central coefficient, which is subtracted from unity.

designers. Each block labelled R designates a register; a series of these elements forms a shift register.

A simple highpass filter (HPF) is formed by subtracting each sample from the previous sample: This filter has weights [1, -1]. The response of this filter is graphed in Figure 20.13. In general, and in this case,

a highpass filter is obtained when a lowpass-filtered version of a signal is subtracted from the unfiltered signal. The unfiltered signal can be considered as a twotap filter having weights [1, 0]. Subtracting the weights

CHAPTER 20

FILTERING AND SAMPLING

203

Figure 20.16 A very simple

IN

5-tap FIR filter comprises

 

four registers and an adder;

 

five adjacent samples are

 

summed. Prior to scaling to

 

unity, the coefficients are

 

[1, 1, 1, 1, 1].

 

R

R

R

R

OUT

A bandpass (bandstop) filter is considered narrowband if its passband (stopband) covers a 2:1 range of frequencies (octave) or less.

If a filter like that of Figure 20.16 has many taps, it needs many adders. Its arithmetic can be simplified by using an accumulator to form the running sum of input samples, another accumulator to form the running sum of outputs from the shift register, and a subtractor to take the difference of these sums. This structure is called a cascaded integrator comb (CIC).

[12, 12] of the scaled lowpass filter from that yields the scaled weights [12, -12] of this highpass filter.

Figure 20.14 shows the response of a filter that adds a sample to the second previous sample, disregarding the central sample. The weights in this case are [1, 0, 1]. This forms a simple bandreject filter (BRF), also known as a bandstop or notch filter, or trap. Here, the response has a null at one quarter the sampling frequency. The scaled filter passes DC with no attenuation. This filter would make a mess of image data – if a picket fence whose pickets happened to lie at a frequency of 0.25fS were processed through this filter, the pickets would average together and disappear! It is a bad idea to apply such a filter to image data, but this filter (and filters like it) can be very useful for signal processing functions.

Figure 20.15 shows the response of a filter that subtracts a sample from the second previous sample, disregarding the central sample. Its weights are

[1, 0, -1]. This forms a simple bandpass filter (BPF). The weights sum to zero – this filter blocks DC. The BPF of this example is complementary to the [1, 0, 1] filter.

Figure 20.16 above shows the block diagram of

a 5-tap FIR filter that sums five successive samples. As shown in the light grey curve in Figure 20.17 at the top of the facing page, this yields a lowpass filter. Its frequency response has two zeros: Any input signal at 0.2fS or 0.4fS will vanish; attenuation in the stopband reaches only about -12 dB, at 310 of the sampling rate.

In the design of digital filters, control of frequency response is exercised in the choice of tap weights. Figure 20.18 at the bottom of the facing page shows the block diagram of a filter having fractional coefficients chosen from a Gaussian waveform. The magenta curve in Figure 20.17 shows that this set of tap weights yields a lowpass filter having a Gaussian frequency response. By using negative coefficients, low-frequency

204

DIGITAL VIDEO AND HD ALGORITHMS AND INTERFACES

Figure 20.17 5-tap FIR filter responses are shown for several choices of coefficient values (tap weights).

 

0

 

 

 

 

 

[dB]

-10

 

 

 

 

 

response

 

 

 

 

 

-20

 

 

 

 

 

Magnitude

 

 

 

 

 

-30

 

 

 

 

 

 

 

 

 

 

 

 

-40

 

 

 

 

 

 

0

0.2π

0.4π

0.6π

0.8π

π

 

 

 

Frequency, ω [rad·s-1]

 

 

response can be extended without deteriorating performance at high frequencies. The black curve in

Figure 20.17 shows the response of a filter having coefficients [-32256, 72256, 176256, 72256, -32256]. This filter exhibits the same attenuation at high frequencies

(about -18 dB) as the Gaussian, but has about twice the -6 dB frequency.

Negative coefficients, as in the last example here, potentially cause production of output samples that exceed unity. (In this example, output samples above unity are produced at input frequencies about ω =0.3π, 16 the sampling rate). If extreme values are clipped, artifacts will result. To avoid artifacts, the signal coding range must include suitable footroom and headroom. The operation of an FIR filter amounts to multiplying

a set of input samples by a set of filter coefficients (weights), and forming the appropriate set of sums of these products. The weighting can be implemented using multipliers or using table lookup techniques. With

Figure 20.18 A 5-tap FIR filter including multipliers has coefficients [13, 56,

118, 56, 13], scaled by 1256. The coefficients approximate

a Gaussian; so does the frequency response. The multipliers can be implemented by table lookup.

IN

R

13

256

R

R

56 118 56

256 256 256

R

13

256

OUT

CHAPTER 20

FILTERING AND SAMPLING

205

IN

R

R

R

R

R

R

R

R

Figure 20.19 A simple comb filter includes several delay elements and an adder.

Figure 20.20 The simple

1.0

 

comb filter’s response

 

 

resembles the teeth of

 

 

a comb. This filter has unity

0.5

 

response at zero frequency:

 

 

It passes DC. A filter having

 

 

weights [12, 0, 0, …, 0,

0

 

-1⁄ ] blocks DC.

0

π

2

 

Frequency, ω [rad·s-1]

 

 

+0.5OUT

+0.5

For details concerning implementation structures, see the books by Lyons and Rorabaugh cited at the end of the chapter.

respect to a complete set of input samples, this operation is called convolution. Ordinarily, convolution is conceptualized as taking place one multiplication at a time. An n-tap FIR filter can be implemented using a single multiplier-accumulator (MAC) component operating at n times the sample rate. A direct implementation with n multiplier components, or a multiplexed implementation with a single MAC, accepts input samples and delivers output samples in temporal order: Each coefficient needs to be presented to the

filter n times. However, convolution is symmetrical with respect to input samples and coefficients: The same set of results can be produced by presenting filter coefficients one at a time to a MAC, and accumulating partial output sums for each output sample. FIR filters have many potential implementation structures.

Figure 20.19 above shows the block diagram of an FIR filter having eight taps weighted [1, 0, 0, …, 0, 1]. The frequency response of this filter is shown in Figure 20.20. The response peaks when an exact integer number of cycles lie underneath the filter; it nulls when an integer-and-a-half number of cycles lie underneath. The peaks all have the same magnitude: The response is the same when exactly 1, 2, …, or n samples are within its window. The magnitude frequency response of such a filter has a shape resembling a comb, and such a filter is called a comb filter.

206

DIGITAL VIDEO AND HD ALGORITHMS AND INTERFACES

Соседние файлы в папке литература