tree2contourlet.m
上传用户:l56789
上传日期:2022-02-25
资源大小:2422k
文件大小:2k
源码类别:

图形图像处理

开发平台:

Matlab

  1. % tree2contourlet.m
  2. % written by: Duncan Po
  3. % Date: August 24, 2002
  4. % convert the contourlet coefficients from tree structure to subband structure
  5. % Usage: coef = tree2contourlet(tree, dir, levndir, nrow, ncol)
  6. % Inputs:   tree        - contourlet coefficients in tree structure
  7. %           dir         - the directional coefficients to be processed
  8. %           levndir     - the number of subbands in each level
  9. %           nrow        - the number of rows in the root subband
  10. %           ncol        - the number of columns in the root subband
  11. % Output:   coef        - contourlet coefficients in subband structure
  12. function coef = tree2contourlet(tree, dir, levndir, nrow, ncol) 
  13. nlevel = length(tree);
  14. M = 2.^levndir(1);
  15. for r = 1:(length(levndir)-1)
  16.     if levndir(r+1)==levndir(r)
  17.         split(r) = 0;
  18.     elseif levndir(r+1)-levndir(r)==1
  19.         split(r) = 1;
  20.     else
  21.         return;
  22.     end;
  23. end;
  24. denoiseddata{1} = reshape(tree{1}, nrow, ncol);
  25. nrow = nrow*2;
  26. ncol = ncol*2;
  27. for lev = 2:nlevel
  28.     denoiseddata{lev} = [];
  29.     for temp = 1:2*nrow:length(tree{lev})        
  30.         buffer = reshape(tree{lev}(temp:temp+2*nrow-1), 2, nrow);
  31.         buffer = buffer.';
  32.         denoiseddata{lev} = [denoiseddata{lev} buffer];
  33.     end;
  34.     nrow = nrow*2; ncol = ncol*2;
  35. end;
  36. clear buffer;
  37. for lev = 1:nlevel
  38.     nump = levndir(lev)-levndir(1); %number of times need to be processed
  39.     buffer{1} = denoiseddata{lev};
  40.     for yy = 1:(nump-1)
  41.         for zz = 2^yy:-2:2
  42.             [buffer{zz-1},buffer{zz}] = type4detransform(buffer{zz/2});
  43.         end;
  44.     end;
  45.     if nump ~= 0
  46.         if (lev~=1) & (split(lev-1)==1)
  47.             for zz = 2^nump:-2:2
  48.                 [buffer{zz-1},buffer{zz}] = type3detransform(buffer{zz/2});
  49.             end;
  50.         else
  51.             for zz = 2^nump:-2:2
  52.                 [buffer{zz-1},buffer{zz}] = type4detransform(buffer{zz/2});
  53.             end;
  54.         end;
  55.     end;
  56.     for zz = 1:2^(levndir(lev)-levndir(1))
  57.         coef{lev}{zz}= buffer{zz};
  58.     end;
  59.     if (dir>M/2) %& (lev>2)
  60.         for yy = 1:2^(levndir(lev)-levndir(1))
  61.             coef{lev}{yy} = coef{lev}{yy}.';
  62.         end;
  63.     end;
  64.     clear buffer;
  65. end;