ARTICLE NO. VC970323
Lossless Image Compression Using the Discrete Cosine Transform
Giridhar Mandyam,*,† Nasir Ahmed,‡ and Neeraj Magotra‡
†Texas Instruments Inc., P.O. Box 660199, Dallas, Texas 75266-0199, ‡Department of Electrical and Computer Engineering, University of New Mexico, Albuquerque, New Mexico 87131
Received March 6, 1995; accepted March 14, 1996
2. THE ALGORITHM In this paper, a new method to achieve lossless compression of
The DCT has long been used as a method for image two-dimensional images based on the discrete cosine transform
(DCT) is proposed. This method quantizes the high-energy coding and has now become the standard for video coding DCT coefficients in each block, finds an inverse DCT from [2]. Its energy compaction capability makes it ideal for only these quantized coefficients, and forms an error residual efficient representation of images. Given a square image sequence to be coded. The number of coefficients used in this block F of size m by m, an m by m matrix C is defined by scheme is determined by using a performance metric for com- the equation:
pression. Furthermore, a simple differencing scheme is per- formed on the coefficients that exploits correlation between
Cij5 1
Ïmi5 0 j 5 0 . . . m 2 1 high energy DCT coefficients in neighboring blocks of an image.
The resulting sequence is compressed by using an entropy coder, and simulations show the results to be comparable to the differ-
5
!
n2cos(2i1 1) jf2m i5 1 . . . m 2 1 j 5 0 . . . m 2 1.ent modes of the lossless JPEG standard. 1997 Academic Press
Thus the DCT of F is defined as 1. INTRODUCTION
f5 CFCT (1)
Compression of images is of great interest in applications
The DCT is a unitary transform, meaning that the inversion where efficiency with respect to data storage or transmis-
can be accomplished by sion bandwidth is sought. Traditional transform-based
methods for compression, while effective, are lossy. In
F5 CTfC. (2)
certain applications, even slight compression losses can have enormous impact. Biomedical images or synthetic-
Unfortunately, the DCT coefficients, i.e., the entries in f, aperture radar images are examples of imagery in which
are evaluated to infinite precision. In traditional coding compression losses can be serious.
methods based on the DCT, all compression and all losses The discrete cosine transform (DCT) has been applied
are determined by quantization of the DCT coefficients.
extensively to the area of image compression. It has excel-
Even for lossless image compression, this problem cannot lent energy-compaction properties, and as a result has been
be avoided, because storing the coefficients to their full chosen as the basis for the Joint Photography Experts’
precision (which is determined by the machine one is using) Group (JPEG) still-picture compression standard. How-
would not yield any compression. What is proposed is to ever, losses usually result from the quantization of DCT
evaluate all entries of the DCT matrix out to only B digits coefficients, where this quantization is necessary to achieve
past the decimal point. This means that the DCT coeffi- compression. In this paper, an alternative lossless method
cients will have precision out to 2B digits past the decimal is proposed which takes advantage of not only the energy
point. A major consequence of this action is that the re- compaction properties of the DCT, but also the correlation
sulting DCT matrix is no longer unitary, and the inverses that exists between high-energy coefficients in neighboring
of the DCT matrix and its transpose must be evaluated transformed blocks of data.
explicitly, i.e.,
* Supported by NASA Grant NAGW 3293 obtained through the Mi- croelectronics Research Center, The University of New Mexico.
F5 C21f(CT)21. (3)
21
1047-3203/97 $25.00 Copyright1997 by Academic Press All rights of reproduction in any form reserved.
since we are transmitting error residuals, the choice of the parameter B, which determines the precision of the transmitted DCT coefficients, becomes less crucial, as in- creasing B will result in little decrease of E in many cases.
For instance, in the 8 by 8 case, experimentation showed that B5 2 was adequate to achieve maximal compression (as stated before, for B5 1 the DCT matrix inverses do FIG. 1. Highest to lowest energy coefficients.
not exist in the 8 by 8 case). The minimum choice of B is case-dependent.
Of course, one must choose B such that these inverses
2.1. Determination of w exist. For instance, in the case where B is 1, i.e., the entries
of C are evaluated to only one place beyond the decimal As one increases the number of high-energy coefficients point, the inverse matrix does not exist in the 8 by 8 pixel retained, the first-order entropy of the entries of E steadily block case. Since the entire operation involves matrix decreases. Unfortunately, a tradeoff exists in that the mem- multiplications, a total of 2m3 multiplications and 2m2 ory required to store the high-energy coefficients increases, (m2 1) additions are required to evaluate all the entries since, even with differencing, these coefficients are still of
of F in (3). relatively high entropy. So one must find a middle point,
Once the DCT coefficients have been computed, we and to do so, the following performance metric called the retain only w high energy coefficients to be used for the potential compression statistic, p, is proposed:
calculation of an approximation to the original data matrix F. One needs to choose w such that a desired amount of
p(w)5
O
ihNo. of bits needed to store w
(5) energy compaction is obtained. The high-energy coeffi-
cients in general will appear in the same locations inside coefficients at block i1 f; e.g. the three highest-energy coefficients always appear
First Order entropy of E at block ij. (6) in f00, f01, and f11, the upper-left corner of f (for a detailed
discussion, see [3]). In Fig. 1, the high to low energy coeffi- cients are scanned for an 8 by 8 DCT block. The remaining
As w increases from 1 to m2(each data block being m by DCT coefficients are assumed to be zero. Then the inverse-
m pixels), p(w) will reach a global minimum. The value of DCT is calculated (without assuming unitarity) and a re-
w at that minimal p(w) is the value used for that particular sulting matrix Fn results. From this, an error residual ma-
image. The main reason that p would vary from one image trix E can be defined:
to another is that a particular scan (Fig. 1) of the high to low energy coefficients in each block has been chosen, and Eij5 Fij2 Fnij. (4)
this scan may not correspond to the actual ordering of these coefficients in a particular block [6]. However, the By retaining E and the w quantized DCT coefficients,
scan that has been chosen has been shown to be optimal perfect reconstruction of F can be achieved.
under the assumption that the data follows a first-order After selecting the high energy DCT coefficients, we
Markov process [7].
perform linear prediction on the nonzero DCT coefficients by using a simple differencing scheme. Between neigh-
boring blocks there exists some correlation between the 3. EXPERIMENTS corresponding high energy coefficients. After specifying w
of these high energy coefficients, each of these coefficients The algorithm was tested on three standard grayscale 256 by 256 pixel images (from the University of Southern can be encoded as the error residual resulting from sub-
tracting the corresponding DCT coefficient from a neigh- California’s image processing database), each quantized
FIG. 4. Moon.
FIG. 2. Cameraman.
to 8 bits per pixel. The original images are shown in Figs. experiments it was found that after deriving the DCT coef- 2–4. An 8 by 8 block was used to obtain the DCT coeffi- ficients for each block, the precision of these coefficients cients. By using the potential compression statistic, it was could be reduced by a factor of 1000 (i.e. three decimal found that the optimal value for w was 3 for all of the digits) without affecting the first-order entropy of the error test images. The value for B was two; moreover, in all residuals; the advantage of this is a reduction in first-order entropy of the DCT coefficients. The proposed method was compared to seven fixed filters for the present lossless JPEG standard (given in Table 1) [10], with the first-order entropy of the error residuals for both methods given Table 2, where the proposed method is designated by ‘‘MDCT,’’
denoting modified DCT. There are three overhead values per block for the MDCT method; for a 256 by 256 image, this implies that there are 3072 overhead values assuming a block size of 8 by 8. For the JPEG lossless filters, the overhead is practically nothing, except for a handful of
TABLE 1
Prediction Modes for Lossless JPEG (a Is a Left-Neighboring Pixel, b Is an Upper-Neighboring Pixel, and c Is an Upper- Left-Neighboring Pixel)
Lossless JPEG filter Method of prediction
JPEG 1 a
JPEG 2 b
JPEG 3 c
JPEG 4 a1 b 2 c
JPEG 5 a1 (b 2 c)/2
JPEG 6 b1 (a 2 c)/2
JPEG 7 (a1 b)/2
FIG. 3. Baboon.
JPEG 7 34.18% 17.67% 35.99%
JPEG 5 5.38 6.86 5.35
JPEG 6 5.31 6.90 5.27
JPEG 7 5.22 6.62 5.05
plied to the seven JPEG modes. An adaptive Huffman coder on the other hand was used to code the overhead startup values for prediction. Knowing this, projected com-
associated with the proposed DCT-based method; this was pression performance was evaluated using the entropy val-
due to the fact that the Rice coder chooses a ‘‘winner’’
ues of Table 2; the results are given in Table 3, where the
out of several fixed entropy coders to compress a sequence, performance criterion used is the percentage size reduction
and for each 8 by 8 image data block, the three low fre- (with respect to the number of bytes) of the original file,
quency coefficients retained for reconstruction are uncor- given by
related and do not in general follow a distribution corre- sponding to these fixed entropy coders. The compression Original File Size2 Compressed File Size
Original File Size 3 100%. (7) results are given in Table 4, from which it can be seen that the proposed method provides very close performance to most of the JPEG lossless modes. It must be noted here It can be seen from the results in Table 3 that the new
that if a Rice coder was to be run in conjunction with any algorithm can be expected to perform approximately as
of the lossless JPEG modes, one would most likely not well as the seven lossless modes of JPEG. However, upon
use such a large block size, as what is gained in reduction application of a standard entropy coder, compression re-
in overhead is lost by a reduction in adaptability. Therefore, sults could end up different than what was predicted. As
in accordance with the recommendations of the JPEG com- an example, a Rice coder ([11, 12]) was used for entropy
mittee, an adaptive Huffman coder was used to do all the coding the error residuals for both the proposed method
coding for each method, with the results given in Table 5.
and the lossless JPEG modes. The advantage of the Rice
Although the performance of the proposed method wors- coder is that it is an adaptive coder which conforms appro-
ens under this kind of entropy coding and the lossless priately to different data blocks without using codebooks;
JPEG modes’ performance improves when compared to this also yields an efficient hardware implementation [12].
the previous Rice coding example, the proposed method The data block size used was 64; this was to take advantage
still outperforms several lossless JPEG modes for each of of the possible differences in entropy between different
the three images.
DCT error residual blocks. This same block size was ap-
TABLE 5 TABLE 3
Projected Compression Results for Test Images Compression Results for Adaptive Huffman Coding
Cameraman Baboon Moon
Cameraman Baboon Moon
MDCT 26.87% 16.12% 33.62% MDCT 24.41% 13.66% 31.98%
JPEG 1 26.59% 26.75% 30.37%
JPEG 1 32.00% 27.75% 31.25%
JPEG 2 33.62% 25.87% 34.62% JPEG 2 31.09% 24.14% 33.91%
JPEG 3 22.65% 22.78% 30.21%
JPEG 3 29.25% 24.75% 31.00%
JPEG 4 30.87% 22.75% 30.25% JPEG 4 28.32% 18.55% 29.57%
JPEG 5 30.63% 12.35% 32.29%
JPEG 5 32.75% 14.25% 33.12%
JPEG 6 33.62% 13.75% 34.12% JPEG 6 31.72% 11.71% 33.30%
JPEG 7 33.12% 16.32% 36.30%
JPEG 7 34.75% 17.25% 36.87%
4. CONCLUSIONS
A new lossless image compression scheme based on the DCT was developed. This method caused a significant re- duction in entropy, thus making it possible to achieve com- pression using a traditional entropy coder. The method performed well when compared to the popular lossless JPEG method. Future work will focus on finding an effi-
cient hardware implementation, possibly taking advantage GIRIDHAR MANDYAM was born in Dallas, Texas on October 15, 1967. He received the B.S.E.E. degree Magna Cum Laude from Southern
of commonality between the new method and the existing
Methodist University in 1989. From 1989 to 1991 he was employed with
DCT-based lossy JPEG method.
Rockwell International in Dallas. From 1991 to 1993 he was a teaching assistant in the Signal and Image Processing Institute (SIPI) at the Univer-
ACKNOWLEDGMENTS
sity of Southern California, where he obtained the M.S.E.E. degree in May 1993. In May 1993, he joined Qualcomm, Inc., in San Diego, CA as an engineer in the Systems Group. In January 1994, he took a leave of absence to pursue doctoral studies at the University of New Mexico The authors thank Mr. Jack Venbrux of the NASA Microelectronics
under a fellowship provided by the NASA Microelectronics Research Research Center at the University of New Mexico for his help with the
Center (MRC) at UNM. He defended his dissertation in December, 1995.
Rice coding algorithm. The authors also thank the anonymous reviewers
He has organized and chaired sessions at the IEEE ISE ’95 Conference for their constructive comments and suggestions.
in Albuquerque, New Mexico; the IEEE Asilomar ’95 Conference in Asilomar, California; and the IEEE ISCAS ’96 Conference in Atlanta,
REFERENCES Georgia. His interests are image coding, image restoration, adaptive algo- rithms, spectral estimation, orthogonal transforms, systolic architectures, and spread spectrum communications. He joined the Wireless R & D 1. G. Mandyam, N. Ahmed, and N. Magotra, A DCT-based scheme group at Texas Instruments in Dallas, Texas in April, 1996.
for lossless image compression, IS&T/SPIE Electronic Imaging Con- ference, San Jose, CA, February, 1995.
2. N. Ahmed, T. Natarajan, and K. R. Rao, Discrete Cosine Transform, IEEE Trans. Comput. C23, January 1974, 90–93.
3. K. R. Rao and P. Yip, Discrete Cosine Transform: Algorithms, Advan- tages, and Applications. Academic Press, San Diego, 1990.
4. A. K. Jain, Fundamentals of Digital Image Processing, Prentice–Hall, Englewood Cliffs, NJ, 1989.
5. M. F. Barnsley, and L. Hurd, Fractal Image Compression, A. K.
Peters, Wellesley, MA, 1993.
6. W. H. Chen and C. H. Smith, Adaptive coding of monochrome and
NASIR AHMED (Fellow, IEEE 1985), was born in Bangalore, India, color images. IEEE Trans. Commun. 25(11), November 1977, 1285–
in 1940. He received the B.S. degree in electrical engineering from the
1292. University of Mysore, India, in 1961, and the M.S. and Ph.D. degrees
7. P. Yip and K. R. Rao, Energy packing efficiency for the generalized from the University of New Mexico in 1963 and 1966, respectively. From discrete transforms, IEEE Trans. Commun. 26(8), August 1978, 1966 to 1968 he worked as a Principal Research Engineer in the area of
1257–1262. information processing at the Systems and Research Center, Honeywell,
Inc., St. Paul, Minnesota. He was at Kansas State University, Manhattan, 8. I. H. Witten, R. M. Neal, and J. G. Cleary, Arithmetic coding
from 1968 to 1983. Since 1983 he has been a Professor of Electrical for data compression, Commun. ACM. 30(6), June 1987, 520–
and Computer Engineering (EECE) at the University of New Mexico, 540.
Albuquerque. In August 1985 he was awarded one of twelve Presidential 9. R. E. Blahut, Principles and Practice of Information Theory, Addi-
Professorships at the University of New Mexico, and was also elected son–Wesley, Menlo Park, CA, 1990.
Fellow of the Institute of Electrical and Electronic Engineers for his 10. P. E. Tischer, R. T. Worley, and A. J. Maeder, Context based lossless
contributions to digital signal processing and engineering education. He image compression, Comput. J. 36(1), January 1993, 68–77.
became the Chairman of the EECE Department in July 1989. He is 11. R. F. Rice, P. S. Yeh, and W. H. Miller, Algorithms for a very the leading author Orthogonal Transforms for Digital Signal Processing high speed university noiseless coding module, JPL Publication (Springer Verlag, 1975), and Discrete-Time Signals and Systems (Reston, 91-1, Pasadena, CA, JPL Publication Office, February 15, 1991. 1983), and co-author of Computer Science Fundamentals (Merrill, 1979).
12. J. Venbrux, P. S. Yeh, and M. N. Liu, A VLSI chip set for high- Dr. Ahmed is also the author of numerous technical papers in the area speed lossless data compression. IEEE Trans. Circuits Syst. Video of digital signal processing. He was an Associate Editor for the IEEE Technol. 2(4), December 1992, 381–391. Transactions on Acoustics, Speech, and Signal Processing (1982–1984) and is currently an Associate Editor for the IEEE Transactions on Electro- 13. R. B. Arps and T. K. Truong, Comparison of international standards
magnetic Compatibility (Walsh Functions Applications). Dr. Ahmed for lossless still image compression, Proceedings of the IEEE. Vol.
served as the Interim Dean of Engineering at the University of New 82. No. 6. June, 1994. pp. 889–899.
Mexico from October 1994 to January 1996. He is now the Interim 14. N. D. Memon and K. Sayood, Lossless image compression: A compar-
Associate Provost for Research and Dean of Graduate Studies at the ative study, IS&T/SPIE Electronic Imaging Conference. San Jose,
University of New Mexico.
CA, February, 1995.
Symposium on Circuits and Systems. He is a member of Sigma Xi, Phi Institute of Technology (Bombay, India) in 1980, his M.S. in Electrical
Kappa Phi, Tau Beta Pi, the Institute of Electrical and Electronics Engi- Engineering from Kansas State University in 1982 and his Ph.D. in Electri-
cal Engineering from the University of New Mexico in 1986. From 1987 neers (IEEE), and the Seismological Society of America. He has authored/co-authored over 70 technical articles including journal papers, until 1990 he held a joint appointment with Sandia National Laboratories
and the Department of Electrical and Computer Engineering (ECE) at conference papers, and technical reports.