rtsColorMapRainbow.m 843 Bytes
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);