rtsApplyBrewer.m 1.08 KB
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);