www.pudn.com > Transforms.rar > s.m, change:2005-05-16,size:937b


function OUT = s(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(j, (b/2)+(index)) = IN(j,k+1) - IN(j,k);                               % H(n) = X(2n+1)-X(2n)
    
        OUT1(j, index) = IN(j,k) + floor((OUT1(j, (b/2)+(index)))/2);               % L(n)=[X(2n)+X(2n+1)]/2

    end
  
    index = index + 1;
  
    k = k + 2;

end
% 以上为行变换
% 以下为列变换

index = 1;

k = 1;

j = 1;

while(j <= a),
  
    for k = 1:b,
    
        OUT((a/2) + (index), k) = OUT1(j+1,k) - OUT1(j, k);
    
        OUT(index, k) = OUT1(j,k) + floor((OUT((a/2) + (index), k))/2);

    end
  
    index = index + 1;
  
    j = j + 2;

end


a = a/2;

b = b/2; %LL子带的大小

count = count+1;

IN = OUT; %更新输出

end