
% auxiliary routine for RWTnoise
% test procedure: image noise reduction by level dependent thresholding
% and non-decimated wavelet transform (+ GCV - estimation)

wcoef = RWT2_BIO(img,M,ht,gt,sht,sgt);
vcoef = RWT2_BIO(noisefree,M,ht,gt,sht,sgt);
wout = wcoef;
label = zeros(size(wcoef));

for j = 1:M
j
  % horizontal component

  w = zeros(size(img));
  w(:,:) = wcoef(j,1,:,:);
  v = zeros(size(img));
  v(:,:) = vcoef(j,1,:,:);
  [wt, thr] = oracle(v,w);
  wout(j,1,:,:) = wt;
  label(j,1,:,:) = (abs(v) > thr);
  oraclethr(j,1) = thr;

  % vertical subband

  w = zeros(size(img));
  w(:,:) = wcoef(j,2,:,:);
  v = zeros(size(img));
  v(:,:) = vcoef(j,2,:,:);
  [wt, thr] = oracle(v,w);
  wout(j,2,:,:) = wt;
  label(j,2,:,:) = (abs(v) > thr);
  oraclethr(j,2) = thr;

  % diagonal subband

  w = zeros(size(img));
  w(:,:) = wcoef(j,3,:,:);
  v = zeros(size(img));
  v(:,:) = vcoef(j,3,:,:);
  [wt, thr] = oracle(v,w);
  wout(j,3,:,:) = wt;
  label(j,3,:,:) = (abs(v) > thr);
  oraclethr(j,3) = thr;

end
imgout = IRT2_BIO(wout,h,g,sh,sg,0.5);
figure(2); image(imgout); colormap(imgmap)
title('level dependent oracle threshold')

