The Real Discrete Fourier Transform of Two-Dimensional Images Russell Herman and Lisa Soberano, University of North Carolina at Wilmington Wilmington, NC Abstract While studying the use of Fourier Transforms in image compression, we have found an interesting application of symmetries in computing discrete Fourier transforms. Such an application could be used as a pedagogical tool to explain the need for periodic extensions in classes in signal processing, image processing, or Fourier analysis. Introduction It is well known that the machinery behind JPEG compression involves the discrete Fourier cosine transform [ref]. In this case one uses the transform and its inverse discrete transform. One such transform pair is given by N 1 (2k 1) X( ) x(k )C ( ) cos , 0, , N 1, 2N k 0 N 1 (2k 1) x(k ) X( )C ( ) cos , k 0, , N 1 2N 0 where C (0) 1 N and C (k ) 2 N if k 0. The two-dimensional discrete cosine transform is a natural extension of this definition. A naïve approach would be to use the Fourier exponential transform and take the real part followed by the real part of the inverse Fourier exponential transform. However, the results of these operations does not return the original figure. For example, if one begins with the images in Figures 1 and 2, Figure 1. Original image of mandrill. the resulting images are those shown below in Figures 3 and 4: Figure 2. Original image of sisters. Figure 3. Image resulting from application of applying discrete Fourier exponential transform to Figure 1, taking the real part, applying inverse transform, and taking its real part. Figure 4. Image resulting from application of applying discrete Fourier exponential transform to Figure 2, taking the real part, applying inverse transform, and taking its real part. These results are easily understood by carefully going through the analysis. The correction, which produces the correct images follows by applying the appropriate extension of the images to a higher period, as will be shown in what follows. One Dimensional Case We first look at the one-dimensional case. As an example, we consider the function f ( x) sin x for 0 x . Then we apply the Fourier exponential transform, take the real part, do the inverse transform, 2 and take its real part. The original function, Figure 5, and the results of these transforms, Figure 6, are shown below: Figure 5. Function f ( x) sin x. 128 points were used to generate this picture. Figure 6. Function resulting from application of applying discrete Fourier exponential transform to Figure 5, taking the real part, applying inverse transform, and taking its real part. We see that these are definitely different functions. To understand the result, we analyze the method. We start with the definitions of the transform and its inverse. fk N 1 n0 fˆn e 2ink / N F 1{ fˆ } 1 N 1 fˆn f k e 2ink / N F{ f } N k 0 Now, compute the discrete transform and take the real part. 1 N 1 2nk Re fˆn f k cos( ) N N k 0 Next, compute the inverse transform of this result, followed by taking its real part. ~ 1 N 1 N 1 2nm 2nk f k Re( F 1{Re fˆ }) f m cos( ) cos( ) N N N n0 m0 Expand the cosine factors in exponential form, multiply out and make use of discrete orthogonality. ~ 1 N 1 N 1 1 2imn / N 1 fk e 2imn / N ] [e 2ink / N e 2ink / N ] f m 2 [e N 2 n0 m0 ~ 1 N 1 N 1 fk f m [e 2i(m k )n / N e 2i(m k )n / N e 2i(k m)n / N e 2in(m k ) / N ] 4N n0 m0 ~ 1 N 1 N 1 fk f m [e 2iN e 2i(m k )n / N e 2i(m k )n / N e 2i(k m)n / N e 2iN e 2in(m k ) / N ] 4N m0 n0 Note that the first term in the brackets indicate that k m is the only surviving term by discrete orthogonality. However, k should an integer from 0 to N-1. We can multiply this term by e 2iN 1 and evaluate the result. Similarly, we can evaluate the last term. This gives ~ 1 N 1 N 1 fk f m[e2i(m( N k )) n / N e2i(mk )n / N e2i(k m)n / N e2in(m(k N )) / N ] 4N m 0 n 0 Now, applying discrete orthogonality, we have ~ 1 N 1 1 fk f m [ N m, N k N m, k N m, k N m, N k ] ( f N k f k ) 4N 2 m0 This indicates that the result is the average of the original and a copy, which has been flipped about the k = N/2. Looking at the last figures, we can see that the second of these is just the average of the original and the reflected copy. In order to avoid the error, we need only perform an extension of the original to the interval 0 x by performing and even extension about x . The extension and the result of 2 applying the real parts of the transform and its inverse are shown Figures 7 and 8. Figure 7. Even extension of function in Figure 5 about x 2. Figure 8.Function resulting from application of applying discrete Fourier exponential transform to Figure 7, taking the real part, applying inverse transform, and taking its real part. Two Dimensional Case Next we consider the two-dimensional transform to see why we had obtained the images shown in the introduction. We start with the two-dimensional Fourier exponential transform and its inverse: 1 fˆuv N f jk N 1 2i ( ju kv) / N f jk e j ,k 0 1 N 1 ˆ 2i ( ju kv) / N f uv e N u ,v 0 Consider the real part of the transform: 1 Re fˆuv N N 1 j, k 0 2 ( ju kv) f jk cos N Inserting the real part of the inverse transform, we obtain ~ 1 N 1 N 1 2 (lu mv ) 2 ( ju kv) f jk f lm cos cos N N N 2 u ,v 0 l , m 0 Expanding the cosines in terms of exponentials, ~ f jk N 1 N 1 1 4N 2 2i (lu m v ju kv) / N e 2i (lu m v ju kv) / N e 2i ( lu m v ju kv) / N e 2i ( lu m v ju kv) / N f lm e u ,v 0 l , m 0 Consider the first term in the brackets. N 1 N 1 1 4N 2 2i (lu m v ju kv) / N f lm e u ,v 0 l , m 0 1 4N 2 N 1 N 1 l ,m 0 u 0 2i (l j ) / N f lm e u N 1 2i ( m k ) / N e v 0 v Summing the geometric series, leads to 1 N 1 N 1 1 N 1 4N 2 u ,v 0 l , m 0 4N 2 l ,m 0 2i (lu m v ju kv) / N f lm e f lm N [ l , N j m, N k ] Similar expressions can be found for the other terms. The fake transform, using only the real parts, gives ~ 1 N 1 1 f jk f N j , N k f jk f lm l , N j m, N k l , j m, k l , j m,k l , j m,k 4 l ,m 0 2 Thus, we see the relationship between the result using the real parts of the Fourier transform and the actual transforms. The first term in the last result is nothing other than the image that has been flipped about both the horizontal and vertical axes. The final result is an average of the two images, the original image and one obtained by flipping the original about a vertical axis through the center followed by a flip about a horizontal axis through the center. This can be corrected by properly preparing the image so that it is invariant under such a transformation. We need a two dimensional extension, which is invariant about the two central axes. Such an extension is shown below with the result of the fake transformation. This is shown using the original images (Figures 1 and 2) presented in the introduction. It is easily seen that the extended images in Fgures 9 and 11 are reproduced under the transformation in Figures 10 and 12. Figure 9. Extension of Figure 1. Figure 10. Image resulting from application of applying discrete Fourier exponential transform to Figure 9, taking the real part, applying inverse transform, and taking its real part. Figure 9. Extension of Figure 1. Figure 12. Image resulting from application of applying discrete Fourier exponential transform to Figure 11, taking the real part, applying inverse transform, and taking its real part. References 1. 2. Hankerson, D. G. A. Harris, and P.D. Johnson, Jr., Introduction to Information Theory and Data Compression, CRC Press, New York, 1998. Jerri, A.J., Integral and Discrete Transforms with Appications and Error Analysis, Marcel Dekker, New York, 1992.