MATLAB Answers


Size increases after encoding

Asked by FIR
on 25 Dec 2012

Finally i got through the problem in huffman encoding,but the size after encoding increases,please help

symbols = unique(YourVector(:));
counts = hist(YourVector(:), symbols);
p = double(counts) ./ sum(counts)
ans =
>> numel(A)
ans =


Log in to comment.


1 Answer

Answer by Walter Roberson
on 25 Dec 2012

Remember, comp is representing binary, and so is 1 bit per element, whereas your original data is at least 8 bits per element.


You cannot reconstruct the compressed image unless you have the table of prefixes and corresponding symbols. So when you save the compressed image, you need to also save the table of prefixes and symbols, and you need to include the size of that saved table when you are calculating the storage space required for the compressed image. The variable I named as "OVER" is the size of that saved table, in bytes.

To calculate the size of that table, you need to figure out the minimum amount of disk storage that you can use to save the table. How to store the table efficiently is going to require some thought on your part.

I would also recommend that you store the dimensions and number of bit planes of the image; if you do not know those, then although you might be able to restore the image contents, you would not be able to figure out the shape the image should be. The size required to store the dimensions and bit planes should be included in the value of OVER.

walter can you please help me in giving the code for restoring image content

Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Win prizes and improve your MATLAB skills

Play today