rtsColorMapRainbow.m
843 Bytes
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
function result = rtsColorMapRainbow(field, minVal, maxVal)
if nargin < 3
maxVal = max(field(:));
end
if nargin < 2
minVal = min(field(:));
end
fieldMaskMin = field >= minVal;
fieldMaskMax = field <= maxVal;
fieldMask = fieldMaskMin;%min(fieldMaskMin, fieldMaskMax);
ctrlPts = zeros(3, 3);
ctrlPts(1, :) = [0.0, 0.0, 0.5];
ctrlPts(2, :) = [0.0, 0.0, 1.0];
ctrlPts(3, :) = [0.0, 1.0, 1.0];
ctrlPts(4, :) = [0.0, 1.0, 0.0];
ctrlPts(5, :) = [1.0, 1.0, 0.0];
ctrlPts(6, :) = [1.0, 0.0, 0.0];
ctrlPts(7, :) = [0.5, 0.0, 0.0];
%X = 0:1/10:1;
X = minVal:(maxVal - minVal)/6: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);