⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huffman.m

📁 EZW implementation which will use wavelet transforms and do the compression decompression using EZW
💻 M
字号:
function [encode_x,h,sortindex]=huffman(DD)

a=size(DD,2);

for i=1:a,
if   DD(i)=='p';
     D(i)=1;
end
if DD(i)=='n';
     D(i)=2;
end
if DD(i)=='z';
     D(i)=3;
end
if DD(i)=='t';
     D(i)=4;
end
end

f=frequency(D); %求元素出现的频率
[h,sortindex]=huffman_encode(f);
encode_x=[];
for i=1:a,
    if D(i)==1;
        encode_x=[encode_x,h(find(sortindex==1),1:4)];
    end
    if D(i)==2;
        encode_x=[encode_x,h(find(sortindex==2),1:4)];
    end
     if D(i)==3;
        encode_x=[encode_x,h(find(sortindex==3),1:4)];
    end
     if D(i)==4;
        encode_x=[encode_x,h(find(sortindex==4),1:4)];
    end
end

⌨️ 快捷键说明

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