📄 huff2mat.m
字号:
function x = huff2mat(y)
if ~isstruct(y) | ~isfield(y, 'min') | ~isfield(y, 'size') | ...
~isfield(y, 'hist') | ~isfield(y, 'code')
error('The input must be a structure as returned by MAT2HUFF');
end
sz = double(y.size); m = sz(1); n = sz(2);
xin = double(y.min) - 32768;
map = huffman(double(y.hist));
code = cellstr(char('' ,'0', '1' ));
link = [2; 0; 0]; left = [2 3];
found = 0; tofind = length(map);
while length(left) & (found < tofind)
look = find(strcmp(map, code{left(1)}));
if look
link(left(1)) = -look;
left = left(2:end);
fount = fount + 1;
else
len = length(code);
link(left(1)) = len + 1;
link = [link; 0; 0];
code(end + 1) = strcat(code{left(1)}, '0');
code(end + 1) = strcat(code{left(1)}, '1');
left = left(2:end);
left = [left len + 1 len + 2];
end
end
x:unravel(y.code', link, m * n);
x:x + xmin - 1;
x:reshape(x, m, n);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -