IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
draw_indexedimage.m
Go to the documentation of this file.
1 %>@ingroup graphicsapi
2 %> @file
3 %> @brief Draws indexed image map
4 %
5 %> @param Y vector with integer values
6 %> @param height
7 %> @param classlabels
8 %> @param direction='ver' Same as irdata.direction
9 function draw_indexedimage(Y, height, direction, classlabels)
10 
11 width = numel(Y)/height;
12 if width ~= floor(width)
13  irerror(sprintf('Invalid height: number of image points not divisible by specified height: %d', height));
14 end;
15 
16 if nargin < 3 || isempty(direction)
17  direction = 'ver';
18 end;
19 if nargin < 4 || isempty(classlabels)
20  classlabels = [];
21 end;
22 
23 
24 legends = classes2legends(Y, classlabels);
25 
26 cm = classes2colormap(Y);
27 cm2 = classes2colormap(Y, 1);
28 
29 
30 uy = unique(Y);
31 for i = 1:numel(uy)
32  h(i) = plot(-1, 0, 's', 'Color', cm2(i, :), 'MarkerSize', 20, 'MarkerFaceColor', cm2(i, :));
33  hold on;
34 end;
35 
36 legend(h, legends);
37 
38 
39 if strcmp(direction, 'hor')
40  M = reshape(Y, width, height)';
41 else
42  M = reshape(Y, height, width);
43 end;
44 imagesc(M);
45 
46 colormap(cm);
47 
48 
49 shading flat;
50 
51 axis image;
52 axis off;
53 set(gca, 'XDir', 'normal', 'YDir', 'normal');
54 set(gca, 'XLim', [1, width], 'YLim', [1, height]);
55 format_frank();
function classes2colormap(in y, in flag_skip)
function classes2legends(in Y, in classlabels)
function irerror(in s)
Dataset class.
Definition: irdata.m:30
Property direction
Definition: irdata.m:107
function format_frank(in F, in scale, in handles)
Analysis Session (AS) base class.
Definition: as.m:6
function draw_indexedimage(in Y, in height, in direction, in classlabels)