save fonction and compression

3 views (last 30 days)
Baptiste
Baptiste on 9 May 2015
Commented: Baptiste on 10 May 2015
Hello!
I see something interesting about the 'save' function: I tried to code a huffman code in order to create a JPEG compression, I finish all technics (DCT, quatization, zigzaig, MLEM, etc...), and i'm stuck about Huffman's Entropy coding.
But I realyse sompething when I save the image's data with "save" fuction: Thie size of the compressed image (starting .bmp 6.000Ko) is reduce as a size like the same than the jpg version (600Ko), so: save function in .m file use the Huffman technique? How can I see the codesource of "save" function?

Accepted Answer

Baptiste
Baptiste on 10 May 2015
Edited: Baptiste on 10 May 2015
I talked about save() function . Ok, obviously, Matwork don't use a common compression algorithm and his function is too particular.
But If I success the Humann coding, and I must save those data, instead of save() who compress a already compressed files, I must use imwrite() or saveas()?
Anyway, I'll try to understand what this Huffman wanted to do with those AC & DC's RLE data for JPEG, I think I will don't sleep during 48 hours -_- .
Thank you for your answer!
  3 Comments
Walter Roberson
Walter Roberson on 10 May 2015
To avoid re-compressing an already compressed binary stream, use fwrite() to write the binary out to a file.
When you are writing a Huffman type compression, remember to take care of the problem that files must store a whole number of bytes but the last Huffman encoding might end in the middle of a byte.
Baptiste
Baptiste on 10 May 2015
I wasn't looking the wikipedia page, now it's clear!
Thank you very much!

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 10 May 2015
The source of "save" is Mathworks proprietary, and it would be very expensive to get access to it unless you get a job with Mathworks.
I can pretty much guarantee that they do not use Huffman encoding. If save() is compressing data at all, it is likely an Lempel–Ziv–Welch type algorithm.
But please check to see if you are talking about save() or about saveas() or about imwrite() as save() does not create .bmp files but the other two do.

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!