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

📄 ardecode.m

📁 常用图像压缩编码码matlab实现。包括:DM编码、变换编码(FFT和DCT)、算术编码、行程编码、Huffman编码、线性预测编码和一个近似的JPEG编码过程。非常适合入门用户实践。
💻 M
字号:
function symseq = ardecode(symbol, pr, codeword, symlen)
%给定字符概率的算术编码
%输出:symse:字符串
%输入:symbol:由字符组成的行向量
%      pr:字符出现的概率
%      codeword:码字
%      symlen:待解码字符串长度
format long
high_range = [];
for k = 1 : length(pr),
    high_range = [high_range sum(pr(1 : k))];
end
low_range = [0 high_range(1 : length(pr) - 1)];
prmin = min(pr);
symseq = [];
symseq = [];
for i = 1 : symlen,
    index = max(find(low_range <= codeword));
    codeword = codeword - low_range(index);
    
    %duo to numerical error, sometimes the encoded number
    %will be slightly smaller than the current lower bound.
    %If this happens, a correction is required.
    if abs(codeword - pr(index)) < 0.01 * prmin,
        index = index + 1;
        codeword = 0;
    end
    symseq = [symseq symbol(index)];
    codeword = codeword/pr(index);
    if abs(codeword) < 0.01 * prmin,
        i = symlen + 1;        %break the for loop immediately
    end
end

⌨️ 快捷键说明

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