wssa1.m

来自「这是伯克里wavelet transforms一书中的例子的代码」· M 代码 · 共 70 行

M
70
字号
function an = wssa1(img,al,ah)
%an = wssa1(array,lpf,hpf) effects a 1 level 2-D separable DWT of the 
%input array using the biorthogonal filter bank defined by the filters
%lpf and hpf. Symmetric extension used to extend array.
%
%This routine is used by analw2d.
%
%Author: Ajit S. Bopardikar
%Copyright (c) 1998 by Addison Wesley Longman, Inc.
%

  [m,n] = size(img);

  ll = length(al);
  lh = length(ah);

  le = (ll-1)/2;
  he = (lh-1)/2;

%determine the appropriate delays depending on the length of the filters
  if ll>lh
    d0 = 0;
    d1 = 1;
  else
    d0 = 1;
    d1 = 0;
  end %end if 
  
%this chooses appropriate delays for the subbands

%first process the rows

  if (n/2 == round(n/2)) %if the number if elements in each row is even
    extl =[img(:,le+1:-1:2) img img(:,n-1:-1:n-le-1)]; %ext for LPF
    exth =[img(:,he+1:-1:2) img img(:,n-1:-1:n-he-1)]; %ext for HPF
    s = conv2(extl,al); 
    anr = s(:,ll+d0:2:ll+n+d0-1); %downsample the columns for LP subband
    s = conv2(exth,ah); 
    anr =  [anr s(:,lh+d1:2:lh+n+d1-1)]'; %downsample and append the HP subband
  else  %...if the number of columns is odd
    extl =[img(:,le+1:-1:2) img img(:,n-1:-1:n-le-1)]; %ext for LPF
    exth =[img(:,he+1:-1:2) img img(:,n-1:-1:n-he-1)]; %ext for HPF
    s = conv2(extl,al); 
    anr = s(:,ll+d0:2:ll+n-1); %downsample the columns for the LP subband
    s = conv2(exth,ah);
    anr =  [anr s(:,lh+d1:2:lh+n-1)]'; %dowsample and append the HP subband     
  end %end if and this completes the rows.

%now process the columns 
%if the number of rows is even then
 
   if (m/2 == round(m/2))
    extl =[anr(:,le+1:-1:2) anr anr(:,m-1:-1:m-le-1)]; %ext for LPF
    exth =[anr(:,he+1:-1:2) anr anr(:,m-1:-1:m-he-1)]; %ext for HPF
    s = conv2(extl,al); 
    an = s(:,ll+d0:2:ll+m+d0-1);%downsamle rows for LP subband
    s = conv2(exth,ah);
    an =  [an s(:,lh+d1:2:lh+m+d1-1)]';%downsample and append HP subband
  else  %...if the number of columns is odd
    extl =[anr(:,le+1:-1:2) anr anr(:,m-1:-1:m-le-1)]; %ext for LPF
    exth =[anr(:,he+1:-1:2) anr anr(:,m-1:-1:m-he-1)]; %ext for HPF
    s = conv2(extl,al); 
    an = s(:,ll+d0:2:ll+m-1); %downsample rows for LP subband
    s = conv2(exth,ah);
    an =  [an s(:,lh+d1:2:lh+m-1)]';%downsample and append HP subband
  end %end if and this completes the columns.    



   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?