I am working on compressing an arbitrary vector with MATLAB, which provides factory methods for Huffman coding: huffmandict, huffmanenco, huffmandeco.
The huffmandict function creates a lookup table that maps each character in the signal that we want to encode to its corresponding code word, which is necessary for encoding and then decoding the signal.
It's trivial to create a dictionary when you know the input vector. But I’ll say that I compress to send Alice to Bob - I can’t assume that Bob also knows the dictionary, so Alice needs to send the dictionary along with the Huffman code!
Is there a way in MATLAB to generate a bitstream representation of a dictionary that needs to be added to our huffman code so that it can be decoded at the other end?
I think the resulting code looks if N is the length of the encoded dictionary:
(N encoded as 8 bits)(huffman dict encoded in N bits)(huffman code)
MATLAB seems to provide fairly powerful factory methods for coding, but then didn't even bother to make it actually useful in digital transmission with a lot of extra work.
I understand that in theory a Huffman tree is often built - is there a way to generate this in MATLAB and then convert that tree back to a dictionary?
source
share