Size of the array after Huffman Encoding

1 view (last 30 days)
Ayesha
Ayesha on 18 Jun 2014
Answered: José-Luis on 18 Jun 2014
Hello,
I have observed that the size of the array generally increasing after huffman encoding process in MATLAB. For example:
sig = repmat([3 3 1 3 3 3 3 3 2 3],1,5); % Data to encode
symbols = [1 2 3]; % Distinct data symbols appearing in sig
p = [0.1 0.1 0.8]; % Probability of each data symbol
dict = huffmandict(symbols,p); % Create the dictionary.
hcode = huffmanenco(sig,dict); % Encode the data.
Here, sig: 1x50 double, however, after encoding, hcode becomes 1x60 double. I thought encoding process would reduce the number of elements. I would appreciate if someone could explain this and if possible, how to determine the size of array after encoding.
Thanks

Answers (1)

José-Luis
José-Luis on 18 Jun 2014
The performance of encoding algorithms will depend on the structure of the underlying data. The combination of structure/algorithm will yield better or worse results depending on the fit. Sometimes you might get a longer file than what you originally had.
If you want to get the size of the array, please look at the built-in function size()

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!