On Discrete Cosine Transform: Jianqin Zhou
On Discrete Cosine Transform: Jianqin Zhou
Jianqin Zhou
1.Telecommunication School, Hangzhou Dianzi University, Hangzhou, 310018 China 2.Computer Science School, Anhui Univ. of Technology, Maanshan, 243002 China [email protected]
AbstractThe discrete cosine transform (DCT), introduced by Ahmed, Natarajan and Rao, has been used in many applications of digital signal processing, data compression and information hiding. There are four types of the discrete cosine transform. In simulating the discrete cosine transform, we propose a generalized discrete cosine transform with three parameters, and prove its orthogonality for some new cases. A new type of discrete cosine transform is proposed and its orthogonality is proved. Finally, we propose a generalized discrete W transform with three parameters, and prove its orthogonality for some new cases. Keywords: Discrete Fourier transform, discrete sine transform, discrete cosine transform, discrete W transform
x(n) cos
k(4qn + r)p , 2N
k = 0, 1, , N 1. There are many new meaningful transforms, such as when (p, q, r) = (1, 1, 1), the new transform is orthogonal. Generally, when gcd(pq, N ) = 1, gcd(pr, 2) = 1, where p, q and r are positive integers, the new transform is orthogonal. In a similar way, we generalize discrete cosine transforms DCT-II-E and DCT-IV-E. Furthermore, a new type of discrete cosine transform, a new type of discrete sine transform and a new type of discrete sine-cosine transform are proposed, and their orthogonality are proved. The discrete W transform (DWT), introduced by Wang Z, has been used in many applications of digital signal processing, data compression and information hiding. The unied form of discrete W transform has two parameters. There are four useful types of the discrete W transform. In simulating the discrete W transform, we propose a generalized discrete W transform with three parameters, and prove its orthogonality for some new cases. II. G ENERALIZED DISCRETE
COSINE TRANSFORM
I. I NTRODUCTION Discrete Fourier transform has been an important tool in many applications of digital signal processing, image processing and information hiding. The appearance of fast fourier transform (FFT) has greatly promoted the rapid development of the subjects above. Ahmed, Natarajan, and Rao (1974) proposed discrete cosine transform dened on real number eld, it can be called DCT-II-E or DCT-III-E (Wang and Hunt,1983). Jain (1974)proposed discrete fourier transform DCT-IV-E, and Wang and Hunt (1983)proposed discrete cosine transform DCT-I-E. The discrete cosine transform has been used in frequency spectrum analysis, data compression, convolution computation and information hiding. Its theory and algorithms have received much attention for the last two decades (Wang and Hunt, 1983, Wang, 1984, August,2004, Kunz,2008). It is demonstrated that the performance of discrete cosine transform can well approximate to ideal K-L transform (Karhunen-Loeve Transform) (Ahmed,Natarajan and Rao,1974). K-L transform was proposed to dealing with a class of extensive stochastic image. After the image being transformed with K-L transform, the image restored from the result is the best approximation to the original image in the statistical sense. Moreover, for the common data model of Markov process, when the correlation coefcient r = 1, KL transform is degraded to the classic DCT transform. In fact, Real-world images are neither stationary nor Markovian. They have different textures and structures, important image structures like edges, arris and lines extend over large distances in the image (Kunz,2008). Therefore, different types of transformation are desirable to meet the different applications. Actually, the discrete cosine transform (DCT-III-E) can be generalized to the unied form with parameters p, q and r, as
Let {x(n); n = 0, 1, 2, , N } be a vector of real numbers. The denitions of four common types of discrete cosine transform (Wang and Hunt,1983) are given as follows: DCT-I-E: X(k) = 2 kn (k) (n)x(n) cos , N N n=0 k = 0, 1, , N, where (k) = (n) = DCT-II-E: X(k) =
N 1 n=0 1 2 N
1
1 2
k = 0 or N else n = 0 or N else
(n)x(n) cos
(2k + 1)n , 2N
k = 0, 1, , N 1,
1 N 2 N
n=0 else
where the above equality follows by cos A cos B = 1 [cos(A B) + cos(A + B)] 2
N 1
Since eix = cos x + i sin x, we consider the real part of the following complex number: ei =
krp 2N
+ ei
k(4q+r)p 2N
ei
krp 2N
+ + ei )
k[4q(N 1)+r]p 2N
x(n) cos
Note that gcd(pq, N ) = 1 and gcd(pr, 2) = 1. When 0 < 2kpq k < 2N , if 1 ei N = 0, then k = N , the real part of ei
krp 2N
1e
i 2kqp N
(1 ei
2kqpN N
+ ei
k(4q+r)p 2N
k = 0, 1, , N 1. Actually, the discrete cosine transform (DCT-III-E) can be generalized to the following unied form with parameters p, q and r: X(k) = (k)
N 1 n=0
+ + ei
k[4q(N 1)+r]p 2N
+ ei
k(4q+r)p 2N
+ + ei
k[4q(N 1)+r]p 2N
=0
x(n) cos
k(4qn + r)p , 2N
(1)
We now prove that when gcd(pq, N ) = 1, gcd(pr, 2) = 1, where p, q and r are positive integers, transform (6) is orthogonal. Transform (6) can be written into matrix form: where X(N ), x(N ) are column vectors of length N,
C(N ) = 1 2 rp cos 2N 2rp cos 2N . . . r cos 2N 2 N 1 2 (4q+r)p 2N 2(4q+r)p cos 2N . . . (4q+r) cos 2N cos 1 2 (8q+r)p 2N 2(8q+r)p cos 2N . . . (8q+r) cos 2N cos . . . 1 2 [4q(N 1)+r]p 2N 2[4q(N 1)+r]p cos 2N . . . [4q(N 1)+r] cos 2N cos
k = 0, 1, , N 1.
From equality (7), when 0 k1 < k2 < N , the inner product of the k1 th row and k2 th row of C(N ) is zero. We know that C(N ) is an orthogonal matrix. Let 0 < k1 < N , the inner product of the k1 th row and itself of C(N ) is that k1 rp 2 k1 (4q + r)p 2 2 {(cos ) + [cos ] + N 2N 2N k1 [4q(N 1) + r]p 2 +[cos ] } 2N 1 k1 rp k1 (4q + r)p = 1 + {cos + cos N N N k1 [4q(N 1) + r]p + + cos } (3) N Note that ei =
krp N
where = (N 1)p To prove that the new transform (1) is orthogonal, or equivalently, to prove that C(N ) is an orthogonal matrix. For 2 1 the sake of simplicity, the coefcients N and 2 is omitted. Let 0 k1 < k2 < N , the inner product of the k1 th row and k2 th row of C(N ) is that k2 rp k1 rp cos cos 2N 2N k2 (4q + r)p k1 (4q + r)p cos + + cos 2N 2N k1 [4q(N 1) + r]p k2 [4q(N 1) + r]p + cos cos 2N 2N (k1 k2 )rp (k1 + k2 )rp 1 {cos + cos = 2 2N 2N (k1 k2 )(4q + r)p (k1 + k2 )(4q + r)p + cos + cos 2N 2N (k1 k2 )[4q(N 1) + r]p + + cos 2N (k1 + k2 )[4q(N 1) + r]p } (2) + cos 2N
+ ei
k(4q+r)p N
e 1
i krp N
4kqp ei N
+ + ei )
k[4q(N 1)+r]p N
(1 ei
4kqpN N
and gcd(pq, N ) = 1 and gcd(pr, 2) = 1. 4kpq When 0 < k < N , if 1 ei N = 0, then 2k = N , the real part of ei
krp 2N
+ ei
k(4q+r)p N
+ + ei
k[4q(N 1)+r]p N
+ ei
k(4q+r)p N
+ + ei
k[4q(N 1)+r]p N
=0
From equality (3), when 0 < k1 < N , the inner product of the k1 th row and itself of C(N ) is 1. We know that the product of C(N ) and its transpose is an identity matrix. Thus, it is easy to get the inverse transform of transform (6). We omit it here. We remark the following three points:
(I) The transpose of C(N ) is an orthogonal matrix, so the transform below is also orthogonal. X(k) =
N 1 n=0
(n)x(n) cos
n(4qk + r)p , 2N
=
k = 0, 1, , N 1. where gcd(pq, N ) = 1, gcd(pr, 2) = 1, p, q and r are positive integers. (II) We can obtain a generalized DCT-IV-E transform, as follows: (2k + 1)(4qn + r)p X(k) = (k) x(n) cos , 4N n=0 k = 0, 1, , N 1. where gcd(pq, N ) = 1, gcd(pr, 2) = 1, p, q and r are positive integers. (III) In a similar way, we can generalize discrete sine transforms, such as DST-II-E, DST-III-E, DST-IV-E.
N 1
(5)
Since eix = cos x + i sin x, we consider the real part of the following complex number: ei 2N 1 + ei 2N 1 + + ei 2k ei 2N 1 i 4k(N 1) 2N 1 ) 4k (1 e i 2N 1 1e
4k 2k 2k3 2k(2N 3) 2N 1
III. A
Let {x(n); n = 0, 1, 2, , N 1} be a vector of real numbers. We dene a new form of discrete cosine transform, as follows:
4 (k) 2N 1
N 1 n=0
X(k) =
(4)
k = 0, 1, , N 1,
By setting =
we have
ei 2N 1 k =N 1 else n=N 1 else = = = = 1 ei 2N 1 cos + i sin 1 cos 2 i sin 2 cos + i sin 2 sin (sin i cos ) (cos + i sin )(sin + i cos ) 2 sin (sin cos )(sin + i cos ) i 2 sin
4k
1
1 2
The transform above can be written into matrix form: X(N ) = C(N ) x(N ) where X(N ), x(N ) are column vectors of length N,
C(N ) = 4 2N 1 cos 2N 1 3 cos 2N 1 3 2N 1 9 cos 2N 1 cos . . . (2N 3) 2N 1 3(2N 3) cos 2N cos . . . (2N 3)(2N 3) cos 2N 1 1 2 1 2 1 2 . . . 1 2 1 2
. . . cos (2N 3) 2N 1 1 2
From equality (5), for 0 k1 < k2 < N 1, the inner product of the k1 th row and k2 th row of C(N ) is 1 1 1 1 ( ) + = 0 2 2 2 2
For the sake of simplicity, the coefcient 2N41 is omitted in the following discussions. Let 0 k1 < k2 < N 1, the
By setting = ei =
(2k+1) 2N 1 ,
we have + + ei
(2k+1)(2N 3) 2N 1
(2k+1) 2N 1
+ ei
(2k+1)3 2N 1
) 1e i (1 + cos i sin ) = 2 sin 1 i = + (1 + cos ) 2 2 sin Now, for 0 k1 < N 1, the inner product of the k1 th row and (N 1)st row of C(N ) is
i 2(2k+1) 2N 1
ei
(2k+1) 2N 1
(1 ei
2(2k+1)(N 1) 2N 1
been used in frequency spectrum analysis, data compression, convolution computation and information hiding. Its theory and algorithms have received much attention for the last two decades (Wang,1989, Wang,1992, Kunz,2008, Zhang,1992). Let {x(n); n = 0, 1, 2, , N 1} be a vector of real numbers. The unied form of discrete W transform is dened (Wang,1984,Wang,1985) as follows: 2 N
N 1 n=0
X(k) =
x(n) sin[
2 + (k + )(n + ) ], 4 N k = 0, 1, , N 1
1 1 1 1 ( ) + ( )( ) = 0 2 2 2 2 Thus, C(N ) is an orthogonal matrix. Equivalently, transform (8) is orthogonal. It is easy to know that the product of C(N ) and its transpose is an identity matrix. Thus, we can get the inverse transform of transform (8). We omit it here. Similarly, we can obtain a new form of discrete sine transform as follows: X(k) = 4 2N + 1
N 1 n=0
The transform above is orthogonal only for (, ) 1 1 1 {(0, 0),( 2 , 0),(0, 2 ),( 1 , 2 )}. It is discrete Hartley transform 2 when (, ) = (0, 0). The four transforms are dened as DWT-I, DWT-II, DWT-III and DWT-IV, respectively. Actually, the unied form of discrete W transform can be added with one more parameter , as follows: X(k) = 2 N
N 1 n=0
x(n) sin[
+ (k + )(n + ) ], 4 N k = 0, 1, , N 1
(6)
x(n) sin
(2k + 1)(2n + 1) , 2N + 1
k = 0, 1, , N 1. And a new form of discrete sine-cosine transform as follows: X(k) = 2 (2k + 1)(2n + 1) , x(n) cos 2N + 1 n=0 2N + 1 k = 0, 1, , N 1; X(N ) = 1 x(n); 2N + 1 n=0
2N 2N
1 This is the proof that when (, , ) = ( 2 , r , 2pq) and q gcd(pq, N ) = 1, where p, q and r are positive integers, transform (6) is orthogonal. For the sake of simplicity, when (, , ) = ( 1 , r , 2pq) and 2 q gcd(pq, N ) = 1, transform (6) is rewritten as follows: N 1 n=0
1 X(k) = N
x(n)cas[(2k + 1)(qn + r)
p ], N
(7)
k = 0, 1, , N 1, where cas x = cos x + sin x. Transform (7) can be written into matrix form:
X(N + 1 + k) =
X(N ) = C(N )x(N ) 2N (2k + 1)(2n + 1) 2 , where X(N ), x(N ) are column vectors of length N, x(n) sin 2N + 1 n=0 2N + 1 1 k = 0, 1, , N 1.
H(N ) = N (q+r)p rp cas cas N N 3(q+r)p 3rp cas cas N N 5(q+r)p 5rp cas cas N N . . . . . . (q+r) r cas cas N N (2q+r)p cas N 3(2q+r)p N 5(2q+r)p cas N . . . (2q+r) cas N cas . . . [q(N 1)+r]p cas N 3[q(N 1)+r]p N 5[q(N 1)+r]p cas N . . . [q(N 1)+r] cas N cas
The orthogonality of above transforms follows from an analysis similar to that of new discrete cosine transform (8). IV. G ENERALIZED DISCRETE W TRANSFORM Bracewell (1983)advanced a discrete Hartlry transform (DHT) in the domain of real numbers. Its nuclear function cas wt = cos wt + sin wt is the sum of the real part and imaginary part of Fourier transform nuclear function exp(iwt) = cos wt + i sin wt. Zhongde Wang (1984)generalized DHT and advanced discrete W transform (DWT), which is an unied form with two parameters. There are four meaningful types (including DHT) in DWT. The nuclear function of DWT is still cas wt = cos wt + sin wt. The discrete W transform has
where = (2N 1)p. To prove that transform (7) is orthogonal, or equivalently, to prove that H(N ) is an orthogonal matrix. It is easy to know that casAcasB = = = (cos A + sin A)(cos B + sin B) cos A cos B + sin A sin B + sin A cos B + cos A sin B cos(A B) + sin(A + B)
To simplify the problem, we omit the coefcient 1 . For N 1 k1 < k2 N , the inner product of the k1 th row and k2 th row of H(N ) is that
(2k1 1)rp (2k2 1)rp cas cas N N (2k1 1)(q + r)p (2k2 1)(q + r)p +cas cas + N N (2k2 1)[q(N 1) + r]p (2k1 1)[q(N 1) + r]p cas +cas N N 2(k1 k2 )rp 2(k1 + k2 1)rp cos + sin N N 2(k1 k2 )(q + r)p 2(k1 + k2 1)(q + r)p + cos + sin N N 2(k1 k2 )[q(N 1) + r]p + cos N 2(k1 + k2 1)[q(N 1) + r]p + sin (8) N
For 1 k1 N , the inner product of the k1 th row of H(N ) and itself is that
(2k1 1)rp 2 (2k1 1)(q + r)p 2 1 {[cas ] + [cas ] + N N N (2k1 1)[q(N 1) + r]p 2 +[cas ] } N 2(2k1 1)rp 2(2k1 1)(q + r)p 1 + sin 1 + {sin N N N 2(2k1 1)[q(N 1) + r]p + + sin } N
+ ei
2k(q+r)p N
+ + ei
2k[q(N 1)+r]p N
+ ei
2k(q+r)p N
i 2krp N
2kqp ei N
+ + ei )
2k[q(N 1)+r]p N
Note that 0 < 2k1 1 < 2N , from the proof above, we know that 2(2k1 1)rp 2(2k1 1)(q + r)p sin + sin N N 2(2k1 1)[q(N 1) + r]p =0 + + sin N It follows that the inner product of the k1 th row of H(N ) and itself is 1 for 1 k1 N , namely the product of H(N ) and its transpose is an identity matrix. Thus, it is easy to get the inverse transform of transform (7), 1 x(k) = N
N 1 n=0
When 0 < k < N and gcd(pq, N ) = 1, we know that 2kqp 1 ei N = 0. Since 1 ei hence ei
2krp N 2kqpN N
(1 ei
2kqpN N
X(n)cas[(2n + 1)(qk + r)
p ], N
k = 0, 1, , N 1, where cas x = cos x + sin x. We should remark the following two points: (I) There is no limit to parameter r in the new transform (2), r is an arbitrary positive integer. (II) In a similar way, we can generalize DWT-IV as follows: 1 X(k) = N
N 1 n=0
= 1 ei2kqp = 0, + + ei
2k[q(N 1)+r]p N
+ ei
2k(q+r)p N
=0
Thus 2(k1 k2 )rp 2(k1 k2 )(q + r)p cos + cos + N N 2(k1 k2 )[q(N 1) + r]p + cos =0 N When 0 < k < 2N , if 1 ei the imaginary part of ei
2krp N 2kqp N
x(n)cas[(2k + 1)(2qn + r)
p ], 2N
k = 0, 1, , N 1 where gcd(pq, N ) = 1, p, q and r are positive integers. It is degraded to transform (2) when r is an even number. Consider two special cases of transform (6): 1 When (, , ) = ( 1 , 2 , 4) and N is an odd number, 2 transform (6) can be written as follows: 1 X(k) = N
N 1 n=0 1 ( 2 , 1 , 2q) q
= 0, then k = N , thus,
2k[q(N 1)+r]p N
+ ei
2k(q+r)p N
+ + ei
+e
i 2k(q+r)p N
Thus,
sin
+ + e
i 2k[q(N 1)+r]p N
=0
x(n)cas
(2k + 1)(2n + 1) , N k = 0, 1, , N 1
2(k1 + k2 1)rp 2(k1 + k2 1)(q + r)p + sin + N N 2(k1 + k2 1)[q(N 1) + r]p =0 + sin N
x(n)cas
From equality (8), the inner product of the k1 th row and k2 th row of H(N ) is zero for 1 k1 < k2 N , namely H(N ) is an orthogonal matrix.
(2k + 1)(qn + 1) , 2N k = 0, 1, , N 1
ACKNOWLEDGMENT The research was supported by Zhejiang Natural Science Foundation (No.Y1100318, R1090138) and Chinese Natural Science Foundation (No. 60802047). R EFERENCES
[1] N. Ahmed, T. Natarajan, and K. R. Rao,(1974). Discrete cosine transform, IEEE Trans. Computer, vol. COM-23, no. 1, pp. 90-93. [2] N.J. August and Dong Sam Ha,(2004). Low power design of DCT and IDCT for low bit rate video codecs, IEEE Trans. Multimedia, Vol. 6, no. 3, pp. 414 - 422. [3] R. N. Bracewell,(1983). Discrete Hartley transform, J. Opt. Soc. Amer., vol. 73, pp. 1832-1835. [4] A. K. Jain,(1979). A sinusoidal family of unitary transform, IEEE Trans. Pattern Anal. Mach. Intell., vol. PAMI-I, pp. 356-365. [5] D. Kunz,(2008). An orientation-selective orthogonal lapped transform, IEEE Trans. Image Process., vol. 17, no. 8, pp.1313-1322. [6] Z. Wang and B. R. Hunt,(1983). The discrete cosine transform-A new version, in Proc. Int. Conf. Acoust., Speech, Signal Processing. [7] Z. Wang,(1984). Fast algorithms for the discrete W transform and for the discrete Fourier transform, IEEE Trans. Acoust., Speech, Signal Process., vol. ASSP-32, no.4, pp. 803-816. [8] Z. Wang and B. R. Hunt,(1985). The discrete W transform, Appl. Math. Comput., vol. 16, pp. 19-48. [9] Z. Wang,(1989). Fast W transform-algorithms and programs, Sci. China (Series A, English Edition), vol. 32, pp. 338-350. [10] Z. Wang,(1992). A prime factor fast W transform algorithm, IEEE Trans. Signal Process., vol.40, no.9 pp. 2361 - 2368. [11] G. Zhang and A. Pan,(1992). The Theory and Applications of Digital Spectrum Method, Beijing: Defence Industry Press.
Jianqin Zhou received his B.Sc. degree in mathematics from East China Normal University, China, in 1983, and M.Sc. degree in probability and statistics from Fudan University, China, in 1989. From 1989 to 1999 he was with the Department of Mathematics and Computer Science, Qufu Normal University, China. From 2000 to 2002, he worked for a number of IT companies in Japan. From 2003 to 2007 he was with the Department of Computer Science, Anhui University of Technology, China. From Sep 2006 to Feb 2007, he was a visiting scholar with the Department of Information and Computer Science, Keio University, Japan. Since 2008 he has been with the Telecommunication School, Hangzhou Dianzi University, China He published more than 70 papers, and proved a conjecture posed by famous mathematician Paul Erd s et al. His research o interests include coding theory, cryptography and combinatorics.