Blame view

rtsColorMapField.m 790 Bytes
8be1ab93   David Mayerich   initial commit of...
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
30
  function Result = rtsColorMapField(F, range)
  %creates a color map for the field F and returns an array with
  %an additional size-3 color dimension
  
  R = zeros(size(F));
  G = zeros(size(F));
  B = zeros(size(F));
  
  %if no range is specified, estimate it using min and max values
  if nargin == 1
      range(1) = min(F(:));
      range(2) = max(F(:));    
  end
  range_size = range(2) - range(1);
  
  num_elements = size(F(:));
  for i =1:num_elements
      if(F(i) > range(1) && F(i) < range(2))
          hue_degrees = (1 - (F(i) - range(1))/range_size)*240;
          HSVval = [hue_degrees 1.0 1.0];
          RGBval = rtsHSVtoRGB(HSVval);
      else
          RGBval = [0 0 F(i)/range(1)];
      end
      R(i) = RGBval(1);
      G(i) = RGBval(2);
      B(i) = RGBval(3);
  end
  Result = cat(ndims(F)+1, R, G, B);
  imshow(Result);