entropy_enco.m

来自「MATLAB编写的huffman编解码程序」· M 代码 · 共 25 行

M
25
字号
function [enco,dict,R] = entropy_enco(index,Nb,Np)

[m,n] = size(index);
% Count the probability & Generate the quantized vector
for j=1:n
    for i=1:m
        if  index(i,j)>0
            sig(index(i,j)) = j;
            if  i==m
                prob(j) = i/Nb;
            end
        else
            prob(j) = (i-1)/Nb;
            break;
        end
    end
end
% Generates the binary Huffman code dictionary
num = 1:n;
[dict,avglen] = huffmanDic(num,prob);
% Huffman coding
enco = huffmanEnco(sig,dict);
% Count compression rate
R = size(enco,2)/(8*Nb*Np);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?