upBlur.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. % RES = upBlur(IM, LEVELS, FILT)
  2. %
  3. % Upsample and blur an image. The blurring is done with filter
  4. % kernel specified by FILT (default = 'binom5'), which can be a string
  5. % (to be passed to namedFilter), a vector (applied separably as a 1D
  6. % convolution kernel in X and Y), or a matrix (applied as a 2D
  7. % convolution kernel). The downsampling is always by 2 in each
  8. % direction.
  9. %
  10. % The procedure is applied recursively LEVELS times (default=1).
  11. % Eero Simoncelli, 4/97.
  12. function res = upBlur(im, nlevs, filt)
  13. %------------------------------------------------------------
  14. %% OPTIONAL ARGS:
  15. if (exist('nlevs') ~= 1)
  16. nlevs = 1;
  17. end
  18. if (exist('filt') ~= 1)
  19. filt = 'binom5';
  20. end
  21. %------------------------------------------------------------
  22. if isstr(filt)
  23. filt = namedFilter(filt);
  24. end
  25. if nlevs > 1
  26. im = upBlur(im,nlevs-1,filt);
  27. end
  28. if (nlevs >= 1)
  29. if (any(size(im)==1))
  30. if (size(im,1)==1)
  31. filt = filt';
  32. end
  33. res = upConv(im,filt,'reflect1',(size(im)~=1)+1);
  34. elseif (any(size(filt)==1))
  35. filt = filt(:);
  36. res = upConv(im,filt,'reflect1',[2 1]);
  37. res = upConv(res,filt','reflect1',[1 2]);
  38. else
  39. res = upConv(im,filt,'reflect1',[2 2]);
  40. end
  41. else
  42. res = im;
  43. end