function wcoef = RWT2_BIO(x,M,ht,gt,sht,sgt)

% RWT2_BIO -- Fast redundant 2D Biorthogonal WT
%  Usage
%    wcoef = RWT2_BIO(x,M,ht,gt,sht,sgt)
%  Inputs
%    x      image
%    M      number of levels
%    ht,sht lp analysis filter
%    gt,sgt hp analysis filter
%  Outputs
%    wcoef  the wavelet coefficients
%  Description
%    Computes Redundant 2D Biorthogonal WT
%  Note
%    wcoef(J,i,:,:) contains coefs at level J 
%      i = 1: horizontal details (HL band)
%      i = 2: vertical details (LH band)
%      i = 1: diagonal details (HH band)
%      LL band in wcoef(M+1,1,:,:)


[n m] = size(x);
w = zeros(M+1,3,n,m);
s = x;
for j=1:M
  whor = RWT_1step(s,j,gt,sgt);
  shor = RWT_1step(s,j,ht,sht);
  w(j,1,:,:) = RWT_1step(shor',j,gt,sgt)';
  w(j,2,:,:) = RWT_1step(whor',j,ht,sht)';
  w(j,3,:,:) = RWT_1step(whor',j,gt,sgt)';
  s = RWT_1step(shor',j,ht,sht)';
end
w(M+1,1,:,:) = s;
wcoef = w;
