file size for encoded image by huffman

3 次查看(过去 30 天)
Hi,anyone can help me how to get file size for image compressed after huffman encode. As i need to find the compression ratio and size of table for compressed image. To store the dictionary and get the size of compressed image.

回答(1 个)

Pramil
Pramil 2024-2-21
I assume that you are using MATLAB's built-in “huffmandict” function to create a Huffman dictionary based on the symbol probabilities and using MATLAB's “huffmanenco” function for generating the encoded image.
You can calculate the size of compressed data in bits by simply finding the length of the encoded data using the "length" function. Divide the same by 8 to get the size of compressed data in bytes.
Now, to find the size of your Huffman dictionary, it will depend upon how you have implemented or stored it. For example, if you save it to a file, you can use “<filename>.bytes” to get the size of your Huffman dictionary.
Finally, to calculate the compression ratio, add the compressed file size and the dictionary size and divide the answer by the file size of the original image.
You can find an example in the file that I have attached.

类别

Help CenterFile Exchange 中查找有关 Denoising and Compression 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by