- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
huffdecode.m
资源名称:work.rar [点击查看]
上传用户:hwtw888
上传日期:2016-03-15
资源大小:177k
文件大小:1k
源码类别:
压缩解压
开发平台:
Matlab
- function vector = huffdecode(zipped, info, image)
- % 函数对输入矩阵vector进行Huffman解码,返回解压后的图像数据
- if ~isa(zipped, 'uint8')
- error('input argument must be be a uint8 vector');
- end
- %产生0,1序列,每位占一个字节
- len = length(zipped);
- string = repmat(uint8(0), 1, len.*8);
- bitindex = 1:8;
- for index = 1:len
- string(bitindex + 8.*(index-1)) = uint8(bitget(zipped(index), bitindex));
- end
- string = logical(string(:)');
- len = length(string);
- string ((len-info.pad+1):end)=[];
- len = length(string);
- %开始解码
- weights = 2.^(0:51);
- vector = repmat(uint8(0), 1, info.length);
- vectorindex = 1;
- codeindex = 1;
- code = 0;
- for index = 1:len
- code = bitset(code, codeindex, string(index));
- codeindex = codeindex+1;
- byte = decode(bitset(code, codeindex), info);
- if byte > 0
- vector(vectorindex) = byte-1;
- codeindex = 1;
- code = 0;
- vectorindex = vectorindex + 1;
- end
- end
- vector = reshape(vector, info.rows, info.cols);
- %函数decode返回码字对应的符号
- function byte = decode(code, info)
- byte = info.huffcodes(code);