www.gusucode.com > 图像压缩编码码matlab实现 > 图像压缩编码码matlab实现/线性预测编码/LPCencode.m

    function y = LPCencode(x, f)
%LPCencode函数用一维无损预测编码压缩图像x,f为预测系数,如果f默认,则f=1,
%就是前值预测。

error(nargchk(1, 2, nargin))
if nargin < 2
    f = 1;
end
x = double(x);
[m, n] = size(x);
p = zeros(m, n);    %存放预测值
xs = x;
zc = zeros(m, 1);
for j = 1: length(f)
    xs = [zc xs(:, 1: end-1)];
    p = p + f(j) * xs;
end
y = x - round(p);