forked from ndwork/dworkLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorImageWithMap.m
More file actions
29 lines (25 loc) · 830 Bytes
/
colorImageWithMap.m
File metadata and controls
29 lines (25 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function colorImg = colorImageWithMap( img, varargin )
% colorImg = colorImageWithMap( img [, cmap ] )
%
% Inputs:
% img - 2D array representing the image
%
% Optional Inputs:
% cmap - the colormap (default is hot)
%
% Written by Nicholas - Copyright 2019
%
% This software is offered under the GNU General Public License 3.0. It
% is offered without any warranty expressed or implied, including the
% implied warranties of merchantability or fitness for a particular
% purpose.
p = inputParser;
p.addOptional( 'mapName', 'hot', @(x) true );
p.parse( varargin{:} );
mapName = p.Results.mapName;
maxImg = max( img(:) );
scaledImg = uint8( img / maxImg * 255 ); %#ok<NASGU>
colorImg = 0;
str2eval = [ 'colorImg = ind2rgb( scaledImg, ', mapName, '(256) );' ];
eval( str2eval );
end