home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / COLOR.DI$ / BRIGHTEN.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.0 KB  |  44 lines

  1. function newmap = brighten(map,beta)
  2. %BRIGHTEN Brighten or darken color map.
  3. %
  4. %    BRIGHTEN(beta) replaces the current color map with a brighter
  5. %    or darker map involving essentially the same colors.  The map is
  6. %    brighter if 0 < beta <= 1 and darker if -1 <= beta < 0.
  7. %
  8. %    BRIGHTEN(beta), followed by BRIGHTEN(-beta) restores the
  9. %    original map.
  10. %   
  11. %    map = BRIGHTEN(beta) returns a brighter or darker version of the
  12. %    color map currently being used without changing the display.
  13. %
  14. %    newmap = BRIGHTEN(map,beta) returns a brighter or darker version
  15. %    of the specified color map without changing the display.
  16.  
  17. %    CBM, 9-13-91, 2-6-92.
  18. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  19.  
  20. if nargin < 2, beta = map; map = colormap; end
  21.  
  22. if max(max(map)) > 1
  23.     map = map/255;
  24. end
  25.  
  26. if (beta > 1) | (beta < -1)
  27.    error('Beta must be between -1 and 1.')
  28. end
  29.  
  30. if beta > 0
  31.    gamma = 1 - min(1,beta);
  32. else
  33.    gamma = 1/(1 + max(-1+eps,beta));
  34. end
  35.  
  36. map = map.^gamma;
  37.  
  38. if nargout == 0
  39.    colormap(map)
  40. else
  41.    newmap = map;
  42. end
  43.  
  44.