wpyrLev.m 729 B

123456789101112131415161718192021222324252627282930
  1. % [LEV,IND] = wpyrLev(PYR,INDICES,LEVEL)
  2. %
  3. % Access a level from a separable QMF/wavelet pyramid.
  4. % Return as an SxB matrix, B = number of bands, S = total size of a band.
  5. % Also returns an Bx2 matrix containing dimensions of the subbands.
  6. % Eero Simoncelli, 6/96.
  7. function [lev,ind] = wpyrLev(pyr,pind,level)
  8. if ((pind(1,1) == 1) | (pind(1,2) ==1))
  9. nbands = 1;
  10. else
  11. nbands = 3;
  12. end
  13. if ((level > wpyrHt(pind)) | (level < 1))
  14. error(sprintf('Level number must be in the range [1, %d].', wpyrHt(pind)));
  15. end
  16. firstband = 1 + nbands*(level-1)
  17. firstind = 1;
  18. for l=1:firstband-1
  19. firstind = firstind + prod(pind(l,:));
  20. end
  21. ind = pind(firstband:firstband+nbands-1,:);
  22. lev = pyr(firstind:firstind+sum(prod(ind'))-1);