Image Compression
Image Compression
1
Mridul Kumar Mathur, 2Seema Loonker, 3Dr. Dheeraj Saxena
1,2
Assistant Professor, Department of Computer Science
Lachoo Memorial College of Science & Technology, Jodhpur
1
[email protected] , 2 [email protected]
“A picture is worth more than thousand words “is a common saying. What a image can communicate can not be
expressed through words. Images play an indispensable role in representing vital information and needs to be saved for
further use or can be transmitted over a medium. In order to have efficient utilization of disk space and transmission
rate, images need to be compressed. Image compression is the technique of reducing the file size of a image without
compromising with the image quality at a acceptable level. This reduction in file size saves disk/.memory space and
allows faster transmission of images over a medium. Image compression is been used from a long time and many
algorithms have been devised. In this paper we have converted an image into an array using Delphi image control tool.
Image control can be used to display a graphical image - Icon (ICO), Bitmap (BMP), Metafile (WMF), GIF, JPEG, etc,
then an algorithm is created in Delphi to implement Huffman coding method that removes redundant codes from the
image and compresses a BMP image file (especially grayscale image) and it is successfully reconstructed. This
reconstructed image is an exact representation of the original because it is lossless compression technique. This
Program can also be applied on other kind of RGB images (BMP, JPEF, Gif, and tiff) but it gives some color quality loss
after reconstruction .Compression ratio for grayscale image is better as compared to other standard methods.
128 + 0 + 0 + 0 + 8 + 4 + 2 + 0 = 142 2. Call a function that will Sort or prioritize characters based
So, now we are able to encode these images using 8-bit on frequency count of each characters in file.
representations of each pixel to code for a specific shade of gray.
Now, once we have coded this image using this method, image 3. Call a function that will create an initial heap. Then reheap
compression is utilized in order to reduce the size of the image that tree according to occurrence of each node in the tree,
down so that fewer bits per pixel are used in the coding of the lower the occurrence earlier it is attached in heap. Create a
image. The idea behind image compression is to use the fewest new node where the left child is the lowest in the sorted list
possible bits per pixel to code the image while still having a and the right is the second lowest in the sorted list.
compressed image comparable to the original image. 4 .Build Huffman code tree based on prioritized list. Chop-
off those two elements in the sorted list as they are now part
of one node and add the probabilities. The result is the
C. TYPES OF IMAGE COMPRESSION probability for the new node.
5. Perform insertion sort on the list with the new node.
Image compression can be bifurcated as lossy and lossless 6. Repeat STEPS 3,4,5 UNTIL you only have 1 node left.
compression.
Lossy compression as the name implies results in loss of some 7. Perform a traversal of tree to generate code table. This
information. The compressed image is similar to the original will determine code for each element of tree in the
uncompressed image but not identical to the previous as in the following way.
process of compression some information regarding the image
has been lost. They are generally suited for photographs. The The code for each symbol may be obtained by tracing a
most common example of lossy compression is JPEG. path to the symbol from the root of the tree. A 1 is
Lossless compression compresses the image by encoding all the assigned for a branch in one direction and a 0 is
information from the original file, so when the image is
decompressed, it will be exactly identical to the original image. assigned for a branch in the other direction. For
Examples of lossless image compression are PNG and GIF. (GIF example a symbol which is reached by branching right
only allows 8-bit images.)When to use a certain image twice, then left once may be represented by the pattern
compression format really depends on what is being compressed. '110'. The figure below depicts codes for nodes of a
sample tree.
2.HUFFMAN CODING:-
*
Proposed by DR. David A. Huffman in 1952. ―A method /\
for the construction of minimum redundancy code .‖ Huffman (0) (1)
code is a technique for compressing data. Huffman's greedy / \
algorithm looks at the occurrence of each character and it as a (10)(11)
binary string in an optimal way. Huffman coding is a form of / \
statistical coding which attempts to reduce the amount of bits (110) (111)
required to represent a string of symbols. The algorithm
accomplishes its goals by allowing symbols to vary in length.
Shorter codes are assigned to the most frequently used symbols, 8. Once a Huffman tree is built, Canonical Huffman codes,
and longer codes to the symbols which appear less frequently in which require less information to rebuild, may be generated by
the string (that's where the statistical part comes in). Code word the following steps:
lengths are no longer fixed like ASCII .Code word lengths vary
and will be shorter for the more frequently used characters. Step 1. Remember the lengths of the codes resulting from a
3.ALORITHM AND WORKING OF HUFFMAN Huffman tree generated per above.
CODING Step 2. Sort the symbols to be encoded by the lengths of their
We have created a code in Delphi for Huffman method. codes (use symbol value to break ties).
Following steps describes working and algorithm for Huffman Step 3. Initialize the current code to all zeros and assign code
values to symbols from longest to shortest code as follows:
coding.
A. If the current code length is greater than the length of
1. Read a BMP image using image box control in Delphi the code for the current symbol, right shift off the extra bits.
language. The TImage control can be used to display a B. Assign the code to the current symbol.
graphical image - Icon (ICO), Bitmap (BMP), Metafile C. Increment the code value.
(WMF), GIF, JPEG, etc. This control will read an image and D. Get the symbol with the next longest code.
convert them in a text file. E. Repeat from A until all symbols are assigned codes.
4. EXPERIMENTAL RESULT
Figure 2: Reconstructed Gray Scale Image This image compression method is well suited for gray scale
(black and white) bit map images .This method can be
improved using adaptive Huffman coding technique that is an
extension to Huffman coding.
References
[1]. Mamta Sharma,‖ Compression Using Huffman Coding‖,
IJCSNS International Journal of Computer Science and Network
Security, VOL.10 No.5, May 2010,pp 133-141
[2] D.A. Huffman, "A Method for the Construction of
Minimum-Redundancy Codes", Proceedings of the I.R.E.,
September 1952, pp 1098–1102. Huffman's original article.
[3] J. Ziv and A. Lempel, "A Universal Algorithm for
Sequential Data Compression", IEEE Transactions on
Information Theory, May 1977.
[4] http://www.dogma.net/markn/index.html
[5] Huffman's original article: D.A. Huffman, "[3]" (PDF),
Proceedings of the I.R.E., sept 1952, pp 1098- 1102
[6] D.E. Knuth — Dynamic Huffman Coding — Journal of
Algorithms, 6, 1983 pp. 163-180.
[7] J.S. Vitter — Design and analysis of Dynamic Huffman
Codes — Journal of the ACM,34#4, 1987, pp. 823-843.
[8] J. Ziv and A. Lempel, ``Compression of Individual
Sequences Via Variable-Rate Coding,'' IEEE Transactions
on Information Theory, Vol. 24, pp. 530--536, 1978.
[9] Chiu-Yi Chen; Yu-Ting Pai; Shanq-Jang Ruan, Low Power
Huffman Coding for HighPerformance Data Transmission,
International Conference on Hybrid Information Technology,
2006, 1(9-11), 2006 pp.71 – 77.
[10] . Lakhani, G, Modified JPEG Huffman coding, IEEE
Transactions Image Processing, 12(2),2003 pp. 159 – 169.
[11] Rudy Rucker, "Mind Tools", Houghton Mifflin
Company,1987
[12] J. Ziv and A. Lempel, ``A Universal Algorithm for
Sequential Data Compression,'' IEEE Transactions on
Information Theory, Vol. 23, pp. 337--342, 1977.
[13] T. A. Welch, ``A Technique for High-Performance Data
Compression,'' Computer, pp. 8--18, 1984
[14] R.G. Gallager — Variation on a theme by Huffman —
IEEE. Trans. on Information Theory,IT-24(6), 1978, pp. 668-
674.
[15] DAVID A. HUFFMAN, Sept. 1991, profileBackground
story: Scientific American, pp. 54-58.
[16] A.B.Watson ,―Image Compression using the DCT‖ ,
Mathematica Journal, 1995,pp.81-88.