File Exchange

image thumbnail

Arithmetic Encoding & Decoding

version 1.0 (2.67 KB) by

Arithmetic coding is a popular encoding technique in compression engines.



View License

Incremental encoding and decoding techniques are implemented.

Comments and Ratings (17)

Ravi Uyyala

Is it possible to compress the binary matrix of size 512*512 by arithmetic coding. If so can you explain how to pass the parametrs. Actually i need to compress the binary location map of size 512*512 by JBIG II technique. But i am unable to do with JBIG II. So, i am trying with this , so can you explain. If you have JBIG II compression technique details. just share the details.

sir, the Tag_bits produced by the encoding part is more than 52 bits and an error asks for Tag_bits w/ less than 52. How can I overcome this problem?

Sir, I am applying Discrete Wavelet transform on an image and then doing quantization. I want to apply arithmetic coding of the quantized signal. How do I go about doing it? Kindly help


Maysa (view profile)

plz sir, how to apply this code after implementing wavelet transform on the selected image?

I get the following error while running the Arithmetic_dec.m file.

??? Input argument "sym" is undefined.

Error in ==> ARM_deco at 10
if(length(sym)==length(p) && sum(p)==1)

Kindly debug the error.


priya (view profile)

respected sir,
how to display an image in the form of a matrix?
how to find the probability of each of the intensities of the image?

Dear Rathnam,

Bitplane coding is nothing but chopping off bits for each image plane (incase of color image) to reduce amount of memory utilized. And important point is that most signifcant bit contains the most information, while the least signifcant bit contains only minute information of image. For example, if you set the 2 LSBs to 0, then you will see a blurred version of the image.
After using bit-plane coding, you may use run-length/level encoding to perform compression.


Respected sir vinay kumar i need Bitplane encoding and decoding for image compression will plz send me


R2F6K (view profile)

can you try to find WTF encooding too?


Dear Vinay Kumar! can u provide me the file provided to Le Hung because i want to use it for the same purpose, thank in advance.

Dear Le Hung,

Its working fine. I have checked after you commented. Please tell me your issue with the execution of code!!

Le Hung

It doesn't work

I don't understand yet. can you write it into .m files please....

After reading the image, You will obtain a matrix of pixel intensities. We know that for a gray-scale image, the intensity values range from 0 to 255. But all the intensities may not be used by the image you have chosen.

For example, a Lena image of 512 x 512 has min. intensity value of 32 and max. intensity value of 192. Also, some of the intensity values b/w 32 and 192 may not be used.

All you have to do is make a list of all the intensity values i.e., 0 - 255 and find out the no. of pixels that belong to each of these intensities. some entries of intensities may have no pixels belonging to it. So, you can discard them and use the intensity values which has non-zero number of pixels belonging to it. And you can divide those numbers in each entry by total number of pixels to obtain the frequency (probability) of each of these intensities in your image. Then these intensities are your symbols with their corresponding probabilities.

Now you have the familiar parameters to use the Arithmetic Coding. :)

I don't understand in step 2 and 3.
can you make an example please..

Any source coding technique is the final step in encoding. If you want to directly implement this method on Image, you need to add a few steps.
1. Read an image using "imread" command.
2. From the image matrix, find out the different intensity values that are used in the image and make out a list of them.
3. Find the freq. of occurence (probability) of each of intensity values in the image.

Now the Intensity values list make up the source symbols and freq. of occurence will be their corresponding probabilities. Then you can supply the those parameters to this function.

I hope i have clarified your question. If not, please elaborate your question.

how to use this function to compress and decompress an image??

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video