Huffman Coding
Huffman Coding
HUFFMAN CODING
a) Code the Sena, Sinan, and Omaha images. List the compression ratios for each of the image
1. Connected to Omega Server using SSH Secure Shell and Basic Unix commands are used
to execute the huff_enc.c file.
2. The output compressed images are observed in the SSH Secure File Transfer.
3. Results
=
clc;
close all; % closes open windows
clear all; % clears previous inputs and values from memory
for i=1:256
DifferImg(i,1)=ReshapeImg(i,1)-128;
end
4. Conclusion
From the above compression ratio results, we can observe the compression ratio
corresponding to pixel difference image is greater than that of Huffman encoded compressed
image.
c) Using the program huff_enc, code the Bookshelf1 and Sena images using the code-book
generated by the Sinan image. Compare the results with the case where the code-book was
generated by the image being compressed
65536
= = = 0.9737
67304
3. Conclusion
The results show that the size of the new image has been increased. In any type of
compression, the compressed image should be of lesser size than that of its original. The main
reason for increment of image size is that, the codebook of sinan image is used to code sena
and bookshelf1 images. As a result, segmentation fault for the images of sena and bookshelf1
has occurred, which is an error in image compression. This error has occurred due to Dynamic
mismatch of the range. Thus the codebook generated for a particular image, should be used for
the operations on that image only. In other words, code book is unique to each image. If used
for other images, results in larger image sizes or undesired outputs.