reconSpyrLevs.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. % RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS)
  2. %
  3. % Recursive function for reconstructing levels of a steerable pyramid
  4. % representation. This is called by reconSpyr, and is not usually
  5. % called directly.
  6. % Eero Simoncelli, 6/96.
  7. function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands)
  8. % Deterimine whether MEX version of upConv is available
  9. is_mex = true;
  10. finfo = functions( @upConv );
  11. if( strcmp( finfo.file((end-2):end), '.m') )
  12. is_mex = false;
  13. end
  14. nbands = size(bfilts,2);
  15. lo_ind = nbands+1;
  16. res_sz = pind(1,:);
  17. % Assume square filters:
  18. bfiltsz = round(sqrt(size(bfilts,1)));
  19. if any(levs > 1)
  20. if (size(pind,1) > lo_ind)
  21. nres = reconSpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)), ...
  22. pind(lo_ind:size(pind,1),:), ...
  23. lofilt, bfilts, edges, levs-1, bands);
  24. else
  25. nres = pyrBand(pyr,pind,lo_ind); % lowpass subband
  26. end
  27. res = upConv(nres, lofilt, edges, [2 2], [1 1], res_sz);
  28. else
  29. res = zeros(res_sz);
  30. end
  31. if any(levs == 1)
  32. ind = 1;
  33. for b = 1:nbands
  34. if any(bands == b)
  35. bfilt = reshape(bfilts(:,b), bfiltsz, bfiltsz);
  36. if( is_mex )
  37. upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ...
  38. bfilt, edges, [1 1], [1 1], res_sz, res);
  39. else
  40. res = upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ...
  41. bfilt, edges, [1 1], [1 1], res_sz, res);
  42. end
  43. end
  44. ind = ind + prod(res_sz);
  45. end
  46. end