-2

I'm doing a Huffman compression in C++ using OpenCV, I already have the codes for the tones of grey but I'm confused about what to do with it. Is there a way to replace the values in the image? Do I have to create other mat?

P.S. My Huffman codes are strings, do I need to change them?

Norton
  • 3
  • 2
  • 1
    I think you need to do a bit more reading on what the huffman coding is doing. The output of Huffman is a table of symbols mapped to their compressed equivalent symbol and a bit-packed string of the compressed symbols. Placing the compressed symbols into a mat likely undoes the bulk of the compression because you are taking the packed data and expanding it back out to a regular data type. You cwant to keep the string in it's compressed form. What you do with it, smurfed if I know. That depends on your use case for compressing it in the first place and your post does not share that information. – user4581301 Apr 15 '16 at 22:33

1 Answers1

0

You need to write something to output bits. Something like:

 void writeBits (unsigned int code, unsigned int codelength) ;

Your output routine needs to add bits to bytes and write the bytes when you've got 8 bits loaded.

user3344003
  • 20,574
  • 3
  • 26
  • 62