function matmap = mk_colmap(type, mid, diff)

val = 0.5;
if nargin < 1 
    type = 4;
end
if type == 3 && nargin > 1
    coef = mid;
end
if type == 3 && nargin > 2
    val = diff;
end
if type == 3 && nargin < 3
    val = 0.5;
end
if type == 3 && nargin < 2
    coef = 0.5;
end
if nargin < 2 || type == 3
    mid = 120;
end
if nargin < 3 
    diff = 90;
end
if type == 3
    diff = 0;  
end

if type == 1 || type == 3
    a = linspace((mid + diff / 2) / 360, (mid - diff / 2) / 360, 256);
    a(a<0) = a(a<0) + 1;
    a(a>1) = a(a>1) - 1;
    a = hsv2rgb([a', linspace(1, 0, 256)', linspace(val, 1, 256)']);    
    matmap = a;
end
if type == 2 || type == 3
    if length(mid) < 3
        mid = [0.0, 0, 1];
%         mid = [0, 1, 0];
    end
    if length(diff)< 3
        diff = [1, 1, 0];
%         diff = [0, 1, 0];
        diff3 = [1, 0, 0];
    end
    b = [linspace(mid(1), diff(1), 256)',...
        linspace(mid(2),diff(2), 256)', linspace(mid(3),diff(3), 256)']; 
%     z = [mid;diff;diff3];
%     x = [1, 256/2, 256];
%     y = 1:3;
%     xnew = 1:256;
%     ynew = 1:3;
%     [x,y] = meshgrid(x,y);
%     [xnew,ynew] = meshgrid(xnew,ynew);
%     b = interp2(x,y,z',xnew,ynew)';
%     b = [[linspace(mid(1), diff(1), 256/2 + 1)' ; linspace(diff(1), diff3(1), 256/2)'],...
%         [linspace(mid(2),diff(2), 256/2 + 1)' ; linspace(diff(2), diff3(2), 256/2)'],...
%         [linspace(mid(3),diff(3), 256/2 + 1)' ; linspace(diff(3), diff3(3), 256/2)']]; 
%     b(256/2+1, :) = [];
    
    matmap = b;
end
if type == 3
%     coef=0.85
%    a = [linspace(0, 1, 256)', linspace(0, 1, 256)', linspace(0,1,256)'];
   matmap = coef*a + (1-coef) * b;
end

if type == 4
   matmap = pmkmp(255);
end

return 
    
