Home > SuperSegger > viz > colorize.m

colorize

PURPOSE ^

colorize : creates an image, with defined mask, colormap, and background

SYNOPSIS ^

function imColorized = colorize( im, mask, colormap_, background )

DESCRIPTION ^

 colorize : creates an image, with defined mask, colormap, and background

 INPUT :
       im : image
       mask : image mask
       colormap : coloramp to be used for image (default jet)
       background : background color (RGB array), (default gray)
 OUTPUT :
       imColorized : final image

 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/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005