A Fast Computational Algorithm for the Discrete Cosine Transform
Total Page:16
File Type:pdf, Size:1020Kb
1004 IEEE TRANSACTIONS ON COMMUNICATIONS, VOL. COM-25, NO. 9, SEPTEMBER 1977 After his military servicehe joined N. V. Peter W. Millenaar was born in Jutphaas, The Philips’ Gloeilampenfabrieken, Eindhoven, Netherlands, on September 6, 1946. He re- where he worked in the fields of electronic de- ceived the degreein electrical engineering at sign of broadcast radio sets, integrated circuits the School of Technology, Rotterdam, in 1967. and optical character recognition. Since 1970 In 1967 he joined the Philips Research Lab- he hasbeen atthe PhilipsResearch Labora- oratories, Eindhoven, The Netherlands, where tories, where he is now working on digital com- he worked in the field of data transmission and munication systems. on the synchronizationaspects of a videophone Mr. Roza is a member of the Netherlands system. Since 1972 he has been engaged in sys- Electronics and Radio Society. tem design and electronics of high speed digital transmission. Concise Papers A Fast Computational Algorithm forthe Discrete Cosine matrix elements to a form which preserves a recognizable bit- Transform reversedpattern at every other node. The generalization is not unique-several alternate methods have been discovered- but the method described herein appears be the simplest WEN-HSIUNG CHEN, C. HARRISON SMITH, AND S. C. FRALICK to to interpret.It is not necessarily themost efficient FDCT which could be constructed but represents one technique for Abstruct-A Fast DiscreteCosine Transform algorithm hasbeen methodical extension. The method takes (3N/2)(log2 N- 1) + developed which provides a factor of six improvement in computational 2 real additions and N logz N - 3N/2 -t 4 real multiplications: complexity when compared to conventional Discrete Cosine Transform this is approximatelysix times as fast as the conventional algorithms using the Fast Fourier Transform. The algorithm is derived approach using a double size FFT. in the form of matrices and illustrated by a signal-flow graph, which may be readily translated to hardware or software implementations. DISCRETE COSINE TRANSFORM INTRODUCTION The discrete cosine transform ofa discrete functionfc), j = The Discrete Cosine Transform (DCT) has been successfully 0, 1, *-, N - 1 is defi.ned as [ 1 ] applied to the coding of high resolution imagery [ 1-51. The conventionalmethod of implementingthe DCT utilized a double size Fast Fourier Transform (FFT) algorithm employing complex arithmetic throughout the computation [ 11. Use of theDCT in a widevariety of applications has not been as k = 0, 1, -., N extensive as its properties would imply due to the lack of an efficientalgorithm. This report describes a moreefficient and the inverse transformis algorithminvolving only real operations for computing the Fast Discrete Cosine Transform (FDCT) of a set of N points. N-1 (2j + 1)kn The algorithm can be extended to any desired value of N = 2”’, m 2 2. The generalization consists of alternating cosine/ k=O [ 2N 1’ sinebutterfly matrices with binary matrices to reorder the j = 0, 1, .-, N Paper approved by the Editor for Communication Theory of the where IEEE Communications Society for publication without oral presenta- tion. Manuscript received January 24, 1977. 1 W.-H. Chen was with the Western Development Laboratories Divi- c(k) = 3 for k = 0 sion, Ford Aerospace and Communications Corporation, Palo Alto, CA 94303. He is now with Compression Laboratories, Inc., Campbell, CA 95008. =1 fork = 1, 2, -., N - 1. C. H. Smith is with the Western Development Laboratories Division, Ford Aerospace and Communications Corporation, Palo Alto, CA Thetransform possesses a highenergy compaction property 94303. which is superiorto any known transform with a fast S. C. Fralick was with the Western Development Laboratories Divi- computational algorithm. [ 1-51 The transform also possesses a sion, Ford Aerospace and Communications Corporation, Palo Alto, CA 94303. He is now with Comtech Advanced Systems, Inc., Sunnyvale, circularconvolution-multiplication relationship which can CA 94086. readily be used in linear system theory.[6] CONCISE PAPERS 1005 A FAST COMPUTATIONAL ALGORITHM where The discrete cosine transform of an N x 1 data vector [f] N can be expressed in a matrix form as [IN/21 is an identity matrix of order - 2 [jN/21 is the opposite diagonal identity matrix kn where [AN] = [c(k)cos (2j + l)kn/2N]; j, k = 0, 1, -*, (N - [Sik]= sin - [I,,,,,~] 1) as defined in equation (1) and [ F] is the N X 1 transformed 2 vector.The fast computational algorithm to be presented hereis based upon the matrix decomposition of the [AN] matrix. As shown below, this matrix can first be written into the following recursive form: where [BN 1 is defined in equation (7), (8) In equations (8) above, the identity matrices [IN/2i] specify the order of the diagonal sine or cosine matrices [Sik],[gik 1, [Cik],[Fik] with the condition that [IN/zi]E 1 for i > N/2. N The four types of matrices may now be described in detail j, k = 0, 1, -., - - 1 L with reference to the right hand sideof equation (9). and [PN]is an N x N permutation matrix which permutes the TYPE 1 transformed vector from a bit reversed order to a natural order. As in all unitary transforms the 2 x 2 DCT can be written as The firstmatrix [MI]is formedby concatenating S2Naj matrices (of order 1) along the upper left to middle of the main diagonal and C2Naj matrices along the middle to lower right.The opposite diagonal is formed by C2~’jmatrices along the upper right to middle and 32~’jmatrices along the It can be seen from the recursive nature of equation (4) that middle to lower left. For this type matrix the values of ai are [A2] can be extended into higher order matrices as long as the binary bit-reversed representation of N/2 + j - 1 for j = there is ageneralized method of decomposingthe [RN/2] 1, 2, *..,NJ2. matrix. The followingdiscussion presents one systematic way of decomposingthe [RN/2] matrix.It is emphasized that this TYPE 2 method of decomposition is not unique and is not optimum. The last matrix [M(2 log2 N - 3)] is formed by concate- Several methods havebeen found which require fewer nating zN/8, - zN/8 matrices along the upper leftto computationalsteps but with no apparent generalization to c41,c41, lowerright of the main diagonal and concatenating 0~18, larger sizes. C4l, F4l, ON/8 matrices along the upper right to lower left The [RN/2] matrix isdecomposed into (2 log2 N - 3) of the opposite diagonal.* matrices in the following manner: TYPE 3 The matrices areof four distinct types. The remaining odd matrices [Mq] are formed by repeated k. concatenation of thematrix sequence zN/2i, - cikj,- si I Type 1 : [Ml ] ,the first matrix and Z~/ziwhere i = N/(2(q-1)/2) for j = 1, 2, ..*, i/8 along Type 2: [M(2 log2 N - 3)],the last matrix the upper left to middle of the main diagonal and the matrix Type 3:[Mql , theremaining odd numbered matrices sequence zN/2i. cikj,sikj and zN/2i for j = iJ8 + 1, -*, i/4 [M31, [MS],etc. alongthe middle to lowerright. The opposite diagonal is Type 4: [Mpl,the evennumbered matrices [M21, [M4], formedsimilarly, using the matrix sequence ON/2i, Sik’, - etc. Fi’j, ON/2i along the upper right to middle and the matrix Beforedescribing the four types of matricesin detail, the sequence ON/2i, - Sikj, Ciki,ON/2i alongthe middle to following definitions are provided for notational efficiency: lowerleft. Repeated concatenation of amatrix sequence alonga diagonal is clearly illustrated in equation (9), where for clarity the havebeen replaced by and etc., zN/2 zN/2 kj’s bj’s ti's, BN =[- because the value of kj depends on the matrix index q. For IN12 --IN12 ] this type matrix, thevalues of the k, are the binary bit-reversed variables (i/4) + j - 1. BN*=[- -IN/, IN12 IN12IN12- ] * Oj is a null matrix of order j. 1006 TRANSACTIONSIEEE ON COMMUNICATIONS, VOL.COM-25, NO. 9, SEPTEMBER 1977 - al -al - S2N a 2n 2 '2N . 0 SaN/4 caN/4 ' 2N 2N 2N a' - N/2-1 -S CaN12-1 2N 2N B2 -aN/2 CaN/2 -9 2N 2N. 0 bl I2 c -C -c 1 - c1 NI2 Nl4 'n14 1 c1 -S bi -S -C- N/2 n14 n14 1 0 12. 0 .. ..- : 0- -5bN/8 N/2 'b - 118 ,bNi8 Nl2 NI2 B8 B8 * B8 . CONCISE PAPERS 1007 TYPE 4 occupiedhalf are oppositethe diagonalson log2 and N - stages are fully occupied on both diagonals. Therefore The evennumbered matrices [Mp] arebinary matrices formed by alternating Bl and Bl* matrices along the upper left N N KRN i2 = (10g2 N - 2) + -(log2 N - 1) to lower right of the main diagonal. The subscript 1 indicates 7 2 the order of the B or B* matrix, and takes on the value of 2F.12. -_3N (1 24 A specificexample of [RN/2]for N = 16 is shownin Eq. - 4 log2 N- N N>4. (10). .1 1.1 11 3n 3n 1 -sir 1 32 co"32 ["3 = 1In In 1-.1 -sir1 cor 32 32 7n 7n -1 1 -sin- 32 co"32 151-1 11 -si- 32 -- 0 1 1 s i+ 1 1 n - '05 1 -1 0 1 -1 1 -1 3Tl cos- -1 1 8 3n COT 1 1 1 1 dL 0 1 0 n n -coq coq nll -cor44 cor nn cos- coy 4 n n coq co"i: 1 I 0 lo 1 The computational steps required for [F]of equation (3) As for the number of multiplications, only the odd matrices can be found from equation (4) with the following recursive consistof multiplicative terms. In these matrices the first relations: matrixconsists of N multipliers,the last matrix consists of (1 la) N/4 multipliers, and the rest of the log; N - 3 matrices each KA~= -k KAN/2 + KR~/2 consists of N/2 multipliers.