Home > bioelectromagnetism > grayish.m

grayish

PURPOSE ^

grayish - gray out the lower end of a spectrum for less severe palette

SYNOPSIS ^

function cmap = grayish(cmap,minval);

DESCRIPTION ^

 grayish - gray out the lower end of a spectrum for less severe palette
 function cmap = grayish(cmap,minval);
 assumes standard two-dimensional color map of three columns

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function cmap = grayish(cmap,minval);
0002 
0003 % grayish - gray out the lower end of a spectrum for less severe palette
0004 % function cmap = grayish(cmap,minval);
0005 % assumes standard two-dimensional color map of three columns
0006 
0007 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0008 
0009 
0010 [m,n] = size(cmap);
0011 
0012 if(length(minval) == 1),
0013   minval = minval + zeros(1,3);
0014 end
0015 
0016 for i = 1:3,
0017  cmap(:,i) = max(cmap(:,i),minval(i)); % set threshold
0018 end
0019 
0020 startndx = 0; % looking for highest index
0021 for i = 1:3,
0022   startndx = max(startndx,min(find(cmap(:,1) > minval(i))));
0023 end
0024 
0025 % so color above this are above the minval
0026 
0027 cmap = cmap(startndx:end,:); % only those values
0028 
0029 % now rescale to full range by interpolating
0030 mtrunc = size(cmap,1); % new length
0031 ndx = [0:(mtrunc-1)]/(mtrunc-1)*(m-1); % scales to new range
0032 
0033 cmap = interp1(ndx,cmap,[0:(m-1)]);
0034 
0035 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003