setPyrBand.m 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. % NEWPYR = setPyrBand(PYR, INDICES, NEWBAND, BAND_NUM)
  2. %
  3. % Insert an image (BAND) into a pyramid (gaussian, laplacian, QMF/wavelet,
  4. % or steerable). Subbands are numbered consecutively, from finest
  5. % (highest spatial frequency) to coarsest (lowest spatial frequency).
  6. % Eero Simoncelli, 1/03.
  7. function pyr = setPyrBand(pyr, pind, band, bandNum)
  8. %% Check: PIND a valid index matrix?
  9. if ( ~(ndims(pind) == 2) | ~(size(pind,2) == 2) | ~all(pind==round(pind)) )
  10. pind
  11. error('pyrTools:badArg',...
  12. 'PIND argument is not an Nbands X 2 matrix of integers');
  13. end
  14. %% Check: PIND consistent with size of PYR?
  15. if ( length(pyr) ~= sum(prod(pind,2)) )
  16. error('pyrTools:badPyr',...
  17. 'Pyramid data vector length is inconsistent with index matrix PIND');
  18. end
  19. %% Check: size of BAND consistent with desired BANDNUM?
  20. if (~all(size(band) == pind(bandNum,:)))
  21. size(band)
  22. pind(bandNum,:)
  23. error('pyrTools:badArg',...
  24. 'size of BAND to be inserted is inconsistent with BAND_NUM');
  25. end
  26. pyr(pyrBandIndices(pind,bandNum)) = vectify(band);