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


function OUT = isp(IN, iterations); 
 
[a,b] = size(IN); 
 
a = a / 2^(iterations-1); 
 
b = b / 2^(iterations-1); 
 
count = 0; 
 
OUT = IN; 
 
OUT1 = IN; 
 
while count < iterations 
 
index = 1; 
 
j = 1; 
 
k = 1; 
 
for k = 1 : b 
     
    IN_Temp((1 + a/2),k) = IN((1 + a/2),k) + floor(IN(2,k)/4); 
     
    IN_Temp(a,k) = IN(a,k) - floor(IN(a/2-1,k)/4); 
     
    for i = 2 : a/2 - 1, 
         
        IN_Temp((i + a/2),k) = IN((i + a/2),k) - floor(IN(i-1,k)/4 - IN(i+1,k)/4 + 0.5); 
         
    end 
     
end 
 
while(j <= a), 
   
    for k = 1:b, 
 
        OUT1(j,k) = IN(index,k) - floor((IN_Temp((index) + (a/2),k))/2); 
     
        OUT1(j+1,k) = OUT1(j,k) + IN_Temp((index) + (a/2),k); 
     
   
    end 
   
    j = j+2; 
   
    index = index+1; 
 
end 
 
k = 1; 
 
j = 1; 
 
index = 1; 
 
for j = 1 : a 
     
    OUT1_Temp(j,(b/2 + 1)) = OUT1(j,(b/2 + 1)) + floor(OUT1(j,2)/4); 
     
    OUT1_Temp(j,b) = OUT1(j,b) - floor(OUT1(j,b/2-1)/4); 
     
    for i = 2 : b/2 - 1, 
         
        OUT1_Temp(j,(b/2 + i)) = OUT1(j,(b/2 + i)) - floor(OUT1(j,i-1)/4 - OUT1(j,i+1)/4 + 0.5); 
         
    end 
     
end 
 
while k <= b, 
   
    for j = 1:a, 
     
        OUT(j,k) = OUT1(j,index) - floor((OUT1_Temp(j, (index) + (b/2)))/2); 
     
        OUT(j, k+1) = OUT(j,k) + OUT1_Temp(j, (index) + (b/2)); 
   
    end 
   
    k = k + 2; 
   
    index = index + 1; 
 
end 
 
count = count + 1; 
 
a = a * 2; 
 
b = b * 2; 
 
IN = OUT; 
 
end