IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
vis_image.m
Go to the documentation of this file.
1 %> @brief Image map
2 %>
3 %> @sa uip_vis_image.m
4 classdef vis_image < vis
5  properties
6  %> =0. 0: feature; 1: class; 2: y
7  mode = 0;
8  %> =1. Index of feature in case @c mode is 0.
9  idx_fea = 1;
10  %> Whether to stretch the image to occupy the whole figure area
11  flag_set_position = 1;
12  end;
13 
14  methods
15  function o = vis_image(o)
16  o.classtitle = 'Image map';
17  o.inputclass = 'irdata';
18  end;
19  end;
20 
21  methods(Access=protected)
22  function out = do_use(o, obj)
23  out = [];
24  if isempty(obj.height) || obj.height < 1
25  irerror('Dataset has no defined image dimensions!');
26  end;
27 
28  % Makes a dataset sorted by number of occurences in the last column
29  if o.mode == 1 % classes
30  Z = obj.classes;
31  Z = renumber_vector_idooo(Z);
32  draw_indexedimage(Z, obj.height, obj.direction, obj.classlabels);
33  elseif o.mode == 0 || o.mode == 2 % feature or Y
34  if o.mode == 0
35  x = obj.X(:, o.idx_fea);
36  elseif o.mode == 2
37  x = obj.Y(:, 1);
38  end;
39 
40  x(obj.classes < 0) = NaN;
41 
42  draw_image(x, obj.height, obj.direction);
43  else
44  irerror(sprintf('Invalid mode: %d', o.mode));
45  end;
46  set_title(o.classtitle, obj);
47 
48  if o.flag_set_position
49  set(gca, 'Position', [0, 0, 1, 1]);
50  end;
51  end;
52  end;
53 end
function irerror(in s)
Dataset class.
Definition: irdata.m:30
function draw_image(in Y, in height, in direction)
Visualization base class.
Definition: vis.m:4
function renumber_vector_idooo(in y)
function set_title(in s, in obj)
Image map.
Definition: vis_image.m:4
function draw_indexedimage(in Y, in height, in direction, in classlabels)