IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
draw_image.m
Go to the documentation of this file.
1 %>@ingroup graphicsapi
2 %> @file
3 %> @brief Draws image map
4 %
5 %> @param Y
6 %> @param height
7 %> @param direction='ver' Same as irdata.direction
8 function draw_image(Y, height, direction)
9 if nargin < 3 || isempty(direction)
10  direction = 'ver';
11 end;
12 
13 width = numel(Y)/height;
14 if width ~= floor(width)
15  irerror(sprintf('Invalid height: number of image points not divisible by specified height: %d', height));
16 end;
17 
18 
19 cc = colormap();
20 ncolors = size(cc, 1);
21 
22 nanana = isnan(Y);
23 Ytemp = Y(~nanana);
24 Ytemp = Ytemp(:);
25 mi = min(Ytemp);
26 ma = max(Ytemp);
27 
28 Y(nanana) = 0;
29 Y(~nanana) = 1+(ncolors-1)*(Y(~nanana)-mi)/(ma-mi);
30 
31 
32 if strcmp(direction, 'hor')
33  M = reshape(Y, width, height)';
34 else
35  M = reshape(Y, height, width);
36 end;
37 imagesc(M);
38 
39 colormap([0, 0, 0; cc]);
40 
41 
42 shading flat;
43 
44 axis image;
45 axis off;
46 set(gca, 'XDir', 'normal', 'YDir', 'normal');
47 set(gca, 'XLim', [0, width+1], 'YLim', [0, height+1]);
48 format_frank();
49 
function irerror(in s)
Dataset class.
Definition: irdata.m:30
function draw_image(in Y, in height, in direction)
Property direction
Definition: irdata.m:107
function format_frank(in F, in scale, in handles)
Analysis Session (AS) base class.
Definition: as.m:6