Mathematical Topics
Total Page:16
File Type:pdf, Size:1020Kb
A Mathematical Topics This chapter discusses most of the mathematical background needed for a thor ough understanding of the material presented in the book. It has been mentioned in the Preface, however, that math concepts which are only used once (such as the mediation operator and points vs. vectors) are discussed right where they are introduced. Do not worry too much about your difficulties in mathematics, I can assure you that mine a.re still greater. - Albert Einstein. A.I Fourier Transforms Our curves are functions of an arbitrary parameter t. For functions used in science and engineering, time is often the parameter (or the independent variable). We, therefore, say that a function g( t) is represented in the time domain. Since a typical function oscillates, we can think of it as being similar to a wave and we may try to represent it as a wave (or as a combination of waves). When this is done, we have the function G(f), where f stands for the frequency of the wave, and we say that the function is represented in the frequency domain. This turns out to be a useful concept, since many operations on functions are easy to carry out in the frequency domain. Transforming a function between the time and frequency domains is easy when the function is periodic, but it can also be done for certain non periodic functions. The present discussion is restricted to periodic functions. 1IIIt Definition: A function g( t) is periodic if (and only if) there exists a constant P such that g(t+P) = g(t) for all values of t (Figure A.la). P is called the period of the function. If several such constants exist, only the smallest of them is considered the period. 694 A.l Fourier Transforms UD (a) (b) Figure A.1: Periodic Functions. A periodic function has four important attributes: its amplitude, period, fre quency, and phase. The amplitude of the function is the maximum value it has in any period. The frequency 1 is the inverse of the period (f = 1/Pl. It is expressed in cycles per second, or Hertz (Hz). The phase is the least understood of the four attributes. It measures the position of the function within a period and it is easy to visualize when a function is compared to its own copy. Examine the two sinusoids in Figure A.lb: They are identical, but out of phase. One follows the other at a fixed interval called the phase difference. We can write them as gl{t) = Asin{2'71"/t) and g2{t) = A sin {211"/t + 0). The phase difference between them is 0, but we can also say that the first one has no phase, while the second one has a phase of O. (By the way, this example also shows that cosine is a sine function with a phase of 0= 7r/2.) To understand the concept of frequency domain, let's look at two simple ex amples. The function g{t) = sin{27rlt) + (1/3) sin{27r{3f)t) is a combination of two sine waves with amplitudes 1 and 1/3 and with frequencies / and 3/, respectively. They are shown in Figure A.2a,b. The sum (Figure A.2c) is also periodic, with frequency 1 (the smaller of the two frequencies). The frequency domain of g(t) is a function consisting of just the two points (f,I) and (3/,1/3) (Figure A.2h). It indicates that the original (time domain) function is made up of frequency 1 with amplitude 1 and frequency 3/ with amplitude 1/3. This example is extremely simple, since it involves just two frequencies. When a function involves several frequencies that are integer multiples of some lowest frequency, the latter is called the fundamental frequency of the function. Not every function has a simple frequency domain representation. Consider the single square pulse in Figure A.2d. Its time domain is (t) = {I, -a/2 ~ t ~ a/2, 9 0, elsewhere, but its frequency domain is as in Figure A.2e. It consists of all the frequencies from o to 00, with amplitudes that drop continuously. This means that the time domain representation, even though simple, consists of all possible frequencies, with lower frequencies contributing more and higher ones contributing less and less. In general, a periodic function can be represented in the frequency domain as the sum of (phase shifted) sine waves with frequencies that are integer mul tiples (harmonicS) of some fundamental frequency. However, the square pulse of Figure A.2d is not periodic. It turns out that frequency domain concepts can be A Mathematical Topics 695 1 r---+---, (a) (d) 1/3 -1/3 Frequency (b) (e) 1 1 0 1/3 Frequency -1 0 0.5 1 1.5 2 0 f 2f 3f (c) (h) Figure A.2: Time and Frequency Domains. applied to a nonperiodic function, but only if it is nonzero over a finite range (like our square pulse). Such a function is represented as the sum of (phase shifted) sine waves with all kinds of frequencies, not just harmonics. The. spectrum of the frequency domain is the range of frequencies it contains. For the function of Figure A.2c,h, the spectrum is the two frequencies f and 3f. For the function of Figure A.2d,e, it is the entire range [O,ooJ. The bandwidth of the frequency domain is the width of the spectrum. It is 2f in our first example and 00 in the second one. Another important concept that should be mentioned is the dc component of the function. The time domain of a function may include a component of zero frequency. Engineers call this component the direct current, so the rest of us have adopted the term "dc component." Figure A.3a is identical to Figure A.2c except 696 A.1 Fourier Transforms that it oscillates from 0 to 2, instead of from -1 to +1. The frequency domain (Figure A.3b) now has an added point at (0,1), representing the dc component. 2 1 1 1/3 Frequency 0 0 0.5 1 1.5 2 0 I 21 31 (a) (b) Figure A.3: Time and Frequency Domains with a dc Component. The entire concept of the two domains is due to the French mathematician Joseph Fourier. He proved a fundamental theorem that says that every periodic function can be represented as the sum of sine and cosine functions. He also showed how to transform a function between the time and frequency domains. If the shape of the function is far from a regular wave, its Fourier expansion will include an infinite number of frequencies. For a continuous function g( t), the Fourier transform and its inverse are given by G(f) = I: g(t) [cos(211"It) - isin(211"It)] dt, g(t) = I: G(f)[cos(211"It) + isin(211"jt)] dj. In computer graphics, we normally have discrete functions that take just n (equally spaced) values. In such a case, the discrete transform is n-l G(f) = Lg(t)[cos(211"It/n) - isin(211"It/n)], 0 ~ I ~ n-1. t=O Its inverse is n-l g(t) = .!. L G(f)[cos(211"It/n) + isin(211"jt/n)], 0 ~ t ~ n-1. n /=0 Note that G(f) is complex, so it can be written G(f) = R(f) +il(f . For any value of I, the amplitude (or magnitude) of G is given by IG(f)1 = R2(f) + 12(f). Note how the function of Figure A.2c that's obtained by adding the simple functions of Figure A.2a,b starts to resemble a square pulse. It turns out that A Mathematical Topics 697 we can bring it closer to a square pulse (like the one of Figure A.1a) by adding (1/5) sin(27r(5f)t), (1/7) sin(27r(7 f)t), and so on. We say that the Fourier series of a square wave with amplitude A and frequency I is the infinite sum 00 1 A L: k sin(27rklt) , k=l where successive terms have smaller and smaller amplitudes. We now apply these concepts to computer graphics. Imagine that we have a black-and-white photograph and we want to store it in the computer so it can be edited and displayed. One way to do this is to scan the photograph line by line. For all practical purposes, we can assume that the photograph has infinite resolution (its shades of gray vary continuously, but see also Section 1.1.7). An ideal scan would, therefore, result in an infinite sequence of numbers and they can be considered the values of an (continuous) intensity function i(t). In practice, we can only store a finite sequence in memory, so we have to select a finite number of values (a sample) i(1), i(2), ... , i(n). This process is known as sampling. Intuitively, sampling seems a trade-off between quality and price. The bigger the sample, the better the quality of the final image, but more hardware (more memory and higher screen resolution) is required, resulting in higher costs. This intuitive conclusion, however, is not completely true. Sampling theory tells us that we can sample an image and reconstruct it in memory without loss of quality if we can do the following: 1. Transform the intensity function from the time domain i(t) to the frequency domain I (I). 2. Find the maximum frequency 1m.