www.pudn.com > Transforms.rar > sp.m, change:2005-05-24,size:1719b


function OUT = sp(IN, iterations); 
 
[a,b] = size(IN); 
 
count = 0;                                                 %计数 
 
OUT = IN;                                                  %初始化输出 
 
while count < iterations, 
 
k = 1; 
 
j = 1; 
 
index = 1; 
 
while k <= b, 
   
    for j = 1:a, 
     
        OUT1_Temp(j, (b/2)+(index)) = IN(j,k+1) - IN(j,k); 
     
        OUT1(j, index) = IN(j,k) + floor((OUT1_Temp(j, (b/2)+(index)))/2); 
         
    end 
   
    index = index + 1; 
   
    k = k + 2; 
 
end 
 
% prediction 
 
for j = 1 : a, 
 
    OUT1(j, (b/2)+1) = OUT1_Temp(j, (b/2)+1) - floor(OUT1(j,2)/4); 
 
    OUT1(j, b) = OUT1_Temp(j,b) + floor(OUT1(j, b/2-1)/4); 
     
    for i = 2 : b/2 - 1, 
 
        OUT1(j, (b/2)+i) = OUT1_Temp(j, (b/2)+i) + floor(OUT1(j, i-1)/4 - OUT1(j, i+1)/4 + 0.5); 
     
    end 
 
end 
 
% END 
 
% 以上为行变换 
 
% 以下为列变换 
 
index = 1; 
 
k = 1; 
 
j = 1; 
 
while j <= a, 
   
    for k = 1 : b, 
     
        OUT_Temp((a/2) + (index), k) = OUT1(j+1,k) - OUT1(j, k); 
     
        OUT(index, k) = OUT1(j,k) + floor((OUT_Temp((a/2) + (index), k))/2); 
 
    end 
   
    index = index + 1; 
   
    j = j + 2; 
 
end 
 
% prediction 
 
for k = 1 : b, 
 
    OUT((a/2) + 1, k) = OUT_Temp((a/2) + 1, k) - floor(OUT(2, k)/4); 
     
    OUT(a, k) = OUT_Temp(a, k) + floor(OUT(a/2-1, k)/4); 
     
    for i = 2 : a/2 - 1, 
         
        OUT((a/2) + i, k) = OUT_Temp((a/2) + i, k) + floor(OUT(i-1, k)/4 - OUT(i+1, k)/4 + 0.5); 
         
    end 
     
end 
 
% END 
 
a = a/2; 
 
b = b/2;                                                  % LL子带的大小 
 
count = count+1; 
 
IN = OUT;                                                 % 更新输出 
 
end