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

  1. function cmap = contrast(x,m);
  2. %CONTRAST Gray scale color map to enhance image contrast.
  3. %
  4. %    CMAP = CONTRAST(X,M) returns a gray scale color map, 
  5. %    that is a M-by-3 matrix with 3 identical columns, so that
  6. %        IMAGE(X)
  7. %        COLORMAP(CMAP)
  8. %    has a roughly equi-distributed gray scale histogram.
  9. %    If M is omitted, the default length 64 is used.
  10.  
  11. %    Cleve Moler 5-8-91, 7-20-91.
  12. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  13.  
  14. if nargin < 2, m = 64; end
  15. xmin = min(min(x));
  16. xmax = max(max(x));
  17. x = round((m-1)*(x-xmin)/(xmax-xmin));
  18. f = find(diff(sort([x(:); (0:m)'])));
  19. f = f/max(f);
  20. cmap = [f f f];
  21.