doColorMap : Applies colormap to an image. INPUT : im_ : image colormap_ : coloramp to be used for image (default jet) caxis_ : OUTPUT : im_new : image with the colormap applied holdcoldinv : inverts hot to cold in colormap. Copyright (C) 2016 Wiggins Lab Written by Paul Wiggins. University of Washington, 2016 This file is part of SuperSegger. SuperSegger is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SuperSegger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SuperSegger. If not, see <http://www.gnu.org/licenses/>.
0001 function im_new = doColorMap( imOriginal, colormap_ , caxis_ ) 0002 % doColorMap : Applies colormap to an image. 0003 % 0004 % INPUT : 0005 % im_ : image 0006 % colormap_ : coloramp to be used for image (default jet) 0007 % caxis_ : 0008 % 0009 % OUTPUT : 0010 % im_new : image with the colormap applied 0011 % 0012 % holdcoldinv : inverts hot to cold in colormap. 0013 % 0014 % 0015 % Copyright (C) 2016 Wiggins Lab 0016 % Written by Paul Wiggins. 0017 % University of Washington, 2016 0018 % This file is part of SuperSegger. 0019 % 0020 % SuperSegger is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % SuperSegger is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with SuperSegger. If not, see <http://www.gnu.org/licenses/>. 0032 0033 0034 0035 if ~exist( 'caxis_', 'var' ) || isempty( caxis_ ) 0036 caxis_ = [min(imOriginal(:)),max(imOriginal(:))]; 0037 end 0038 0039 im = double((imOriginal-caxis_(1)))/double((caxis_(2)-caxis_(1))); 0040 im(im<0)=0; 0041 im(isnan(im)) = 0; 0042 ss_c = size(colormap_); 0043 0044 im = floor( ss_c(1)*im)+1; 0045 im(im>ss_c(1))=ss_c(1); 0046 0047 ss = size( im ); 0048 im_new = im(:); 0049 im_new = colormap_(im_new,:); 0050 im_new = reshape( im_new, [ss,3]); 0051 0052 end