File Exchange

image thumbnail

A DWT based lossless gray Image Compression

version (234 KB) by Said BOUREZG
a technique of gray image compression using the discrete wavelet transform is presented in this code


Updated 28 Feb 2015

View License

In this code, a new hybrid technique using the discrete wavelet transform (DWT) is presented. We show evaluation using the Power Signal to Noise Ratio (PSNR) as a measure of quality, we show that DWT with threshold, Quantization, and combination of RLE and Huffman as coding stage, provides a better performance than JPEG in terms of PSNR and we can get an important CR.
Our Algorithm is like that:
Reading image-->DWT transformation-->Thresholding-->Quantization-->RLE encoding--> Huffman encoding-->Save a compressed image in file (*.Hdwt)
in decompression steps we should open file(*.Hdwt) aafter that the steps will be like that: Huffman decoding-->RLE decoding--> Quantization inverse-->IDCT transformation-->Open image as Bmp image
main code to compress an image we only run compdct.m
To reconstruct our image we mean here if we want to decompress the file obtained before (.Hdwt) only we run this code and chose the file interested.
proba.m: frequency calculation.
rle.m: Run length encoding
irle.m: Inverse Run length encoding
abais.m: reduce value big than 255

Cite As

Said BOUREZG (2020). A DWT based lossless gray Image Compression (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)


I confim it DOES NOT work on any other image.

aram salehi

no it dose not work for other images just work for bird image

jihen saoud

Hi Mr Said, we apply a quantization in a compression algorithm, we can then say that it is a lossless compression? I think that's not the case.


@Devajyoti Borah it's work with all other images.

okay, i figured it out. thank you!

Can you please explain why isn't any compression in the original and compressed data? Although you are employing RLE as well but the sizes of both both files are same.

this code is only run for bird image which is given in the zip.other images are not !


Any one can improve this code by adding a Arithmetic coding stage or removing RLE.

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux