PageRenderTime 35ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/pixeldup.m

https://bitbucket.org/tetonedge/diptoolbox
Objective C | 33 lines | 28 code | 5 blank | 0 comment | 4 complexity | f0bd7b4d176a2d39f227b65a6159f136 MD5 | raw file
  1. function B = pixeldup(A, m, n)
  2. %PIXELDUP Duplicates pixels of an image in both directions.
  3. % B = PIXELDUP(A, M, N) duplicates each pixel of A M times in the
  4. % vertical direction and N times in the horizontal direction.
  5. % Parameters M and N must be integers. If N is not included, it
  6. % defaults to M.
  7. % Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
  8. % Digital Image Processing Using MATLAB, Prentice-Hall, 2004
  9. % $Revision: 1.5 $ $Date: 2005/01/03 00:01:28 $
  10. % Check inputs.
  11. if nargin < 2
  12. error('At least two inputs are required.');
  13. end
  14. if nargin == 2
  15. n = m;
  16. end
  17. % Generate a vector with elements 1:size(A, 1).
  18. u = 1:size(A, 1);
  19. % Duplicate each element of the vector m times.
  20. m = round(m); % Protect against nonintegers.
  21. u = u(ones(1, m), :);
  22. u = u(:);
  23. % Now repeat for the other direction.
  24. v = 1:size(A, 2);
  25. n = round(n);
  26. v = v(ones(1, n), :);
  27. v = v(:);
  28. B = A(u, v);