图像压缩背景知识
图像冗余包括编码冗余、像素间冗余、心理视觉冗余。
编码冗余
减少编码冗余
function h = entropy(x, n)
% 熵
error(nargchk(1, 2, nargin)); % Check input arguments
if nargin < 2
n = 256; % Default for n.
end
x = double(x); % Make input double
xh = hist(x(:), n); % Compute N-bin histogram
xh = xh / sum(xh(:)); % Compute probabilities
% Make mask to eliminate 0's since log2(0) = -inf.
i = find(xh);
h = -sum(xh(i) .* log2(xh(i))); % Compute entropy
霍夫曼编码