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, Ma’anshan, 243002 China
[email protected]
2N
In simulating the discrete cosine transform, we propose a n=0
generalized discrete cosine transform with three parameters, and k = 0, 1, · · · , N − 1.
prove its orthogonality for some new cases. A new type of discrete
cosine transform is proposed and its orthogonality is proved. There are many new meaningful transforms, such as when
Finally, we propose a generalized discrete W transform with three (p, q, r) = (1, 1, 1), the new transform is orthogonal. Gener-
parameters, and prove its orthogonality for some new cases.
ally, when gcd(pq, N ) = 1, gcd(pr, 2) = 1, where p, q and r
Keywords: Discrete Fourier transform, discrete sine transform,
discrete cosine transform, discrete W transform
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
I. I NTRODUCTION cosine transform, a new type of discrete sine transform and a
new type of discrete sine-cosine transform are proposed, and
Discrete Fourier transform has been an important tool in their orthogonality are proved.
many applications of digital signal processing, image process- The discrete W transform (DWT), introduced by Wang Z,
ing and information hiding. The appearance of fast fourier has been used in many applications of digital signal process-
transform (FFT) has greatly promoted the rapid development ing, data compression and information hiding. The unified
of the subjects above. Ahmed, Natarajan, and Rao (1974) form of discrete W transform has two parameters. There are
proposed discrete cosine transform defined on real number four useful types of the discrete W transform. In simulating
field, it can be called DCT-II-E or DCT-III-E (Wang and the discrete W transform, we propose a generalized discrete W
Hunt,1983). Jain (1974)proposed discrete fourier transform transform with three parameters, and prove its orthogonality
DCT-IV-E, and Wang and Hunt (1983)proposed discrete co- for some new cases.
sine transform DCT-I-E. The discrete cosine transform has
been used in frequency spectrum analysis, data compression, II. G ENERALIZED DISCRETE COSINE TRANSFORM
convolution computation and information hiding. Its theory
Let {x(n); n = 0, 1, 2, · · · , N } be a vector of real numbers.
and algorithms have received much attention for the last two
The definitions of four common types of discrete cosine
decades (Wang and Hunt, 1983, Wang, 1984, August,2004,
transform (Wang and Hunt,1983) are given as follows:
Kunz,2008).
DCT-I-E:
It is demonstrated that the performance of discrete co-
r N
sine transform can well approximate to ideal K-L trans- 2 X knπ
form (Karhunen-Loeve Transform) (Ahmed,Natarajan and X(k) = α(k) α(n)x(n) cos ,
N n=0
N
Rao,1974). K-L transform was proposed to dealing with a
class of extensive stochastic image. After the image being k = 0, 1, · · · , N,
transformed with K-L transform, the image restored from the where
result is the best approximation to the original image in the
√1
statistical sense. Moreover, for the common data model of 2
k = 0 or N
α(k) =
Markov process, when the correlation coefficient r = 1, K- 1 else
L transform is degraded to the classic DCT transform. In √1
2
n = 0 or N
fact, Real-world images are neither stationary nor Markovian. α(n) =
1 else
They have different textures and structures, important image
structures like edges, arris and lines extend over large dis- DCT-II-E:
tances in the image (Kunz,2008). Therefore, different types of N −1
transformation are desirable to meet the different applications.
X (2k + 1)nπ
X(k) = α(n)x(n) cos ,
Actually, the discrete cosine transform (DCT-III-E) can be n=0
2N
generalized to the unified form with parameters p, q and r, as k = 0, 1, · · · , N − 1,
q
1
n=0 where the above equality follows by
where α(n) = qN
2
else 1
cos A cos B = [cos(A − B) + cos(A + B)]
N
DCT-III-E: 2
N
X −1
k(2n + 1)π Since eix = cos x + i sin x, we consider the real part of the
X(k) = α(k) x(n) cos , following complex number:
n=0
2N
krpπ k(4q+r)pπ k[4q(N −1)+r]pπ
k = 0, 1, · · · , N − 1, ei 2N + ei 2N + · · · + ei 2N
krpπ
ei
q 2N
1 2kqpπN
k=0 = (1 − ei N )
where α(k) = qN 1−e i 2kqpπ
N
2
N else
Note that gcd(pq, N ) = 1 and gcd(pr, 2) = 1. When 0 <
DCT-IV-E: 2kpqπ
r N −1
k < 2N , if 1 − ei N = 0, then k = N , the real part of
2 X (2k + 1)(2n + 1)π
X(k) = x(n) cos , krpπ k(4q+r)pπ k[4q(N −1)+r]pπ
N n=0 2N ei 2N + ei 2N + · · · + ei 2N
k = 0, 1, · · · , N − 1. is zero.
2kpqπ
Actually, the discrete cosine transform (DCT-III-E) can be If 1 − ei N 6= 0, then
generalized to the following unified form with parameters p, krpπ k(4q+r)pπ k[4q(N −1)+r]pπ
q and r: ei 2N + ei 2N + · · · + ei 2N =0
N
X −1
k(4qn + r)pπ From equality (7), when 0 ≤ k1 < k2 < N , the inner
X(k) = α(k) x(n) cos , (1) product of the k1 th row and k2 th row of C(N ) is zero. We
2N
n=0 know that C(N ) is an orthogonal matrix.
k = 0, 1, · · · , N − 1.
We now prove that when gcd(pq, N ) = 1, gcd(pr, 2) = Let 0 < k1 < N , the inner product of the k1 th row and
1, where p, q and r are positive integers, transform (6) is itself of C(N ) is that
orthogonal. 2 k1 rpπ 2 k1 (4q + r)pπ 2
Transform (6) can be written into matrix form: {(cos ) + [cos ] + ···
N 2N 2N
X(N ) = C(N ) · x(N ) k1 [4q(N − 1) + r]pπ 2
+[cos ] }
where X(N ), x(N ) are column vectors of length N, 2N
1 k1 rpπ k1 (4q + r)pπ
= 1 + {cos + cos
q
C(N ) = 2
N
√1
2
√1
2
√1
2
··· √1
2
N N N
cos
rpπ
cos
(4q+r)pπ
cos
(8q+r)pπ
··· cos
[4q(N −1)+r]pπ
k1 [4q(N − 1) + r]pπ
2N 2N 2N 2N
+ · · · + cos } (3)
2(4q+r)pπ 2(8q+r)pπ 2[4q(N −1)+r]pπ
2rpπ
cos cos cos cos
N
···
2N 2N 2N 2N
. . . . .
. . . . .
Note that
. . . . .
ηr η(4q+r) η(8q+r) η[4q(N −1)+r]
cos cos cos ··· cos
2N 2N 2N 2N krpπ k(4q+r)pπ k[4q(N −1)+r]pπ
where η = (N − 1)pπ ei N + ei N + · · · + ei N
i krpπ
To prove that the new transform (1) is orthogonal, or e N 4kqpπN
= 4kqpπ (1 − ei N )
equivalently, to prove that C(N ) is anqorthogonal matrix. For 1− ei N
the sake of simplicity, the coefficients N2 and √12 is omitted. and gcd(pq, N ) = 1 and gcd(pr, 2) = 1.
4kpqπ
Let 0 ≤ k1 < k2 < N , the inner product of the k1 th row When 0 < k < N , if 1 − ei N = 0, then 2k = N , the
and k2 th row of C(N ) is that real part of
k1 rpπ k2 rpπ
cos cos krpπ k(4q+r)pπ k[4q(N −1)+r]pπ
2N 2N ei 2N + ei N + · · · + ei N
integers. ei 2N −1 + ei 2N −1 + · · · + ei 2N −1
2kπ
(III) In a similar way, we can generalize discrete sine ei 2N −1 i 4k(N −1)π
= 4kπ (1 − e
2N −1 )
transforms, such as DST-II-E, DST-III-E, DST-IV-E. i 2N
1 − e −1
4kπ
When 0 < k < 2N − 1, 1 − ei 2N −1 6= 0.
III. A NEW TYPE OF DISCRETE COSINE TRANSFORM Note that
4kπ(N −1)
Let {x(n); n = 0, 1, 2, · · · , N − 1} be a vector of real ei 2N −1
where X(N ), x(N ) are column vectors of length N, Thus, the real part of
r
C(N ) = 4 2k(2N −3)π
2kπ 2k3π
cos π
2N −1
cos 3π ··· cos
(2N −3)π
−√ 1 ei 2N −1 + ei 2N −1 + · · · + ei 2N −1
2N −1 2N −1 2N −1 2
3(2N −3)π
cos 3π cos 9π ··· cos −√ 1
2N −1 2N −1 2N
2
is i
2 sin(α) i sin(α) = − 21 .
. . . . .
. . . . .
. . . . .
cos (2N −3)π (2N −3)3π (2N −3)(2N −3)π 1
cos ··· cos −√
2N −1 2N −1 2N −1
From equality (5), for 0 ≤ k1 < k2 < N − 1, the inner
2
−√ 1 −√ 1 ··· −√ 1 −1
2 2 2 2
product of the k1 th row and k2 th row of C(N ) is
q
For the sake of simplicity, the coefficient 2N4−1 is omitted 1 1 1 1
in the following discussions. Let 0 ≤ k1 < k2 < N − 1, the (− − ) + = 0
2 2 2 2
(2k+1)π
By setting α = 2N −1 , we have been used in frequency spectrum analysis, data compression,
(2k+1)π (2k+1)3π (2k+1)(2N −3)π
convolution computation and information hiding. Its theory
ei 2N −1 + ei 2N −1 + · · · + ei 2N −1
and algorithms have received much attention for the last two
(2k+1)π
ei 2N −1 2(2k+1)(N −1)π decades (Wang,1989, Wang,1992, Kunz,2008, Zhang,1992).
= (1 − ei) 2N −1
Let {x(n); n = 0, 1, 2, · · · , N − 1} be a vector of real
i 2(2k+1)π
1−e 2N −1
numbers. The unified form of discrete W transform is defined
i
= (1 + cos α − i sin α) (Wang,1984,Wang,1985) as follows:
2 sin α
1 i
= + (1 + cos α) r N −1
2 2 sin α 2 X π 2π
X(k) = x(n) sin[ + (k + α)(n + β) ],
Now, for 0 ≤ k1 < N − 1, the inner product of the k1 th N n=0 4 N
row and (N − 1)st row of C(N ) is k = 0, 1, · · · , N − 1
1 1 1 1 The transform above is orthogonal only for (α, β) ∈
(− √ ) + (− )(− √ ) = 0
2 2 2 2 {(0, 0),( 21 , 0),(0, 21 ),( 12 , 21 )}. It is discrete Hartley transform
Thus, C(N ) is an orthogonal matrix. Equivalently, trans- when (α, β) = (0, 0). The four transforms are defined as
form (8) is orthogonal. DWT-I, DWT-II, DWT-III and DWT-IV, respectively.
It is easy to know that the product of C(N ) and its Actually, the unified form of discrete W transform can be
transpose is an identity matrix. Thus, we can get the inverse added with one more parameter γ, as follows:
transform of transform (8). We omit it here. r N −1
2 X π γπ
X(k) = x(n) sin[ + (k + α)(n + β) ], (6)
Similarly, we can obtain a new form of discrete sine N n=0 4 N
transform as follows: k = 0, 1, · · · , N − 1
N
This is the proof that when (α, β, γ) = ( 21 , rq , 2pq) and
r −1
4 X (2k + 1)(2n + 1)π
X(k) = x(n) sin , gcd(pq, N ) = 1, where p, q and r are positive integers,
2N + 1 n=0 2N + 1
transform (6) is orthogonal.
k = 0, 1, · · · , N − 1.
For the sake of simplicity, when (α, β, γ) = ( 12 , rq , 2pq) and
And a new form of discrete sine-cosine transform as fol- gcd(pq, N ) = 1, transform (6) is rewritten as follows:
lows:
r 2N N −1
2 X (2k + 1)(2n + 1)π 1 X pπ
X(k) = x(n) cos , X(k) = √ x(n)cas[(2k + 1)(qn + r) ], (7)
2N + 1 n=0 2N + 1 N n=0 N
k = 0, 1, · · · , N − 1; k = 0, 1, · · · , N − 1,
r 2N where cas x = cos x + sin x.
1 X
X(N ) = − x(n);
2N + 1 n=0 Transform (7) can be written into matrix form:
r 2N
X(N ) = C(N )x(N )
2 X (2k + 1)(2n + 1)π
X(N + 1 + k) = x(n) sin , where X(N ), x(N ) are column vectors of length N,
2N + 1 n=0 2N + 1 1 H(N ) = √
N
k = 0, 1, · · · , N − 1.
cas
rpπ
N
cas
(q+r)pπ
N
cas
(2q+r)pπ
N
··· cas
[q(N −1)+r]pπ
N
i 2krpπ
e N 2kqpπN
= 2kqpπ (1 − ei N ) N −1
1 X pπ
1− ei N x(k) = √ X(n)cas[(2n + 1)(qk + r) ],
N n=0 N
When 0 < k < N and gcd(pq, N ) = 1, we know that
2kqpπ k = 0, 1, · · · , N − 1,
1 − ei N 6= 0. Since
2kqpπN where cas x = cos x + sin x.
1 − ei N = 1 − ei2kqpπ = 0,
hence We should remark the following two points:
2krpπ 2k(q+r)pπ 2k[q(N −1)+r]pπ
(I) There is no limit to parameter r in the new transform
ei N + ei N + · · · + ei N =0 (2), r is an arbitrary positive integer.
(II) In a similar way, we can generalize DWT-IV as follows:
Thus
N −1
2(k1 − k2 )rpπ 2(k1 − k2 )(q + r)pπ 1 X pπ
cos + cos + X(k) = √ x(n)cas[(2k + 1)(2qn + r) ],
N N N n=0 2N
2(k1 − k2 )[q(N − 1) + r]pπ k = 0, 1, · · · , N − 1
· · · + cos =0
N
2kqpπ
where gcd(pq, N ) = 1, p, q and r are positive integers. It is
When 0 < k < 2N , if 1 − ei N = 0, then k = N , thus, degraded to transform (2) when r is an even number.
the imaginary part of
2krpπ 2k(q+r)pπ 2k[q(N −1)+r]pπ Consider two special cases of transform (6):
ei N + ei N + · · · + ei N
When (α, β, γ) = ( 12 , 21 , 4) and N is an odd number,
is zero. transform (6) can be written as follows:
2kqpπ
When 0 < k < 2N and if 1 − ei N 6= 0, then 1 X
N −1
(2k + 1)(2n + 1)π
2krpπ 2k(q+r)pπ 2k[q(N −1)+r]pπ X(k) = √ x(n)cas ,
ei N + ei N + · · · + ei N =0 N n=0 N
Thus, k = 0, 1, · · · , N − 1
sin
2(k1 + k2 − 1)rpπ
+ sin
2(k1 + k2 − 1)(q + r)pπ
+ ··· When (α, β, γ) = ( 21 , 1q , 2q) and gcd(q, N ) = 1, transform
N N (6) can be written as follows:
2(k1 + k2 − 1)[q(N − 1) + r]pπ
+ sin =0 N −1
N 1 X (2k + 1)(qn + 1)π
X(k) = √ x(n)cas ,
N n=0 2N
From equality (8), the inner product of the k1 th row and
k = 0, 1, · · · , N − 1
k2 th row of H(N ) is zero for 1 ≤ k1 < k2 ≤ N , namely
H(N ) is an orthogonal matrix. We know that transforms above are orthogonal.
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.