Code covered by the BSD License  

Highlights from
Toolbox image

from Toolbox image by Gabriel Peyre
A toolbox that contains image processing functions

apply_colormap(M,col)
function A = apply_colormap(M,col)

if nargin<2
    col = 'gray';
end
switch col
    case 'gray'
        c = gray(256);
    case 'jet'
        c = jet(256);
    otherwise
        error('Unknown colormap.');
end

M = round(rescale(M,1,256));

A = zeros([size(M) 3]);
for i=1:3
    A(:,:,i) = reshape( c(M,i), size(M) );
end

Contact us