Blame view

stim/matlab/rtsApplyBrewer.m 1.08 KB
1ff9af85   David Mayerich   added MATLAB/OCTA...
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
31
32
33
34
35
36
37
38
39
40
41
  function result = rtsApplyBrewer(field, minVal, maxVal)

  

  if nargin < 3

      maxVal = max(field(:));

  end

  if nargin < 2

      minVal = min(field(:));

  end

  

  fieldMaskMin = field >= minVal;

  fieldMaskMax = field <= maxVal;

  

  fieldMask = min(fieldMaskMin, fieldMaskMax);

  

  ctrlPts = zeros(11, 3);

  

  ctrlPts(1, :) = [0.192157, 0.211765, 0.584314];

  ctrlPts(2, :) = [0.270588, 0.458824, 0.705882];

  ctrlPts(3, :) = [0.454902, 0.678431, 0.819608];

  ctrlPts(4, :) = [0.670588, 0.85098, 0.913725];

  ctrlPts(5, :) = [0.878431, 0.952941, 0.972549];

  ctrlPts(6, :) = [1, 1, 0.74902];

  ctrlPts(7, :) = [0.996078, 0.878431, 0.564706];

  ctrlPts(8, :) = [0.992157, 0.682353, 0.380392];

  ctrlPts(9, :) = [0.956863, 0.427451, 0.262745];

  ctrlPts(10, :) = [0.843137, 0.188235, 0.152941];

  ctrlPts(11, :) = [0.647059, 0, 0.14902];

  

  %X = 0:1/10:1;

  X = minVal:(maxVal - minVal)/10:maxVal;

  

  R = interp1(X, ctrlPts(:, 1), field);

  G = interp1(X, ctrlPts(:, 2), field);

  B = interp1(X, ctrlPts(:, 3), field);

  

  R = R.* fieldMask;

  G = G.* fieldMask;

  B = B.* fieldMask;

  

  result = cat(ndims(field)+1, R, G, B);