Skip to content

Latest commit

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Data Compression

This repository includes two projects on image compression and was developed for the course Data Compression at National Taiwan Normal University in Taipei, fall of 2014.

The two projects were implemented in Java and handle encoding and decoding of grayscale, 256 bit, image files. Although being in the same repository, the lossless and lossy projects are independent. The results are based on running the codec on the five RAW images given in the testdata folder.

Table of Contents

Author

Marcus Windmark, http://windmark.se

Compiling

Either import the individual projects with an IDE of your choice or manually compile the java files in the src folder. Instructions regarding execution can be found under respective segment.

Lossless Image Compression

Adaptive Huffman Coding was used to implement the Lossless Codec. It was implemented by sequentially inserting into a binary tree and balancing according to the algorithm of Adaptive Huffman Code.

Executing

After compiling, the following commands can be run.

Encoding: java AdaptiveHuffmanEncode input_file output_file output_huffman_table_file Decoding: java AdaptiveHuffmanDecode input_file output_file

Results

FileRaw Size (b)Encoded Size (b)Space Saving
test1192000018026876.11%
test21920000127221833.74%
test31920000156624218.42%
test41920000148852022.47%
test519200001921055-0.05%

Average encoding speed of 400 ms, decoding speed of 300 ms.

Lossy Image Compression

The implementation of the Lossy Codec uses Discrete Cosine Transform (DCT) and Scalar Quantization together with the same Adaptive Huffman Coding as the lossless codec. Togethery, they form an algorithm of Basic JPEG.

Executing

After compiling, the following commands can be run.

Encoding: java TransformImageEncode raw_file encoded_file Decoding: java TransformImageDecode encoded_file decoded_file SNR: java SignalToNoiseRatio original_file decoded_file

Results

FileRaw Size (b)Encoded Size (b)Space SavingCompression RatioSNREncoding Time (ms)Decoding Time (ms)
test1192000038365480.02%5.0026.84836825
test2192000026675486.11%7.2017.73848780
test3192000031721383.48%6.0527.88785777
test4192000031005683.85%6.1926.27807773
test5192000086731954.83%2.2118.00973859

References

  1. Donald E Knuth, Dynamic huffman coding, Journal of Algorithms, Volume 6, Issue 2, June 1985, Pages 163-180, ISSN 0196-6774, http://dx.doi.org/10.1016/0196-6774(85)90036-7.

About

Implementations of both lossless and lossy data compression.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages