MATLAB File Help: cv.applyColorMap Index
cv.applyColorMap

Applies a GNU Octave/MATLAB equivalent colormap on a given image

dst = cv.applyColorMap(src, colormap)

Input

Output

The human perception isn't built for observing fine changes in grayscale images. Human eyes are more sensitive to observing changes between colors, so you often need to recolor your grayscale images to get a clue about them. OpenCV now comes with various colormaps to enhance the visualization in your computer vision application.

Example

In OpenCV you only need cv.applyColorMap to apply a colormap on a given image. The following sample code takes an image and applies a Jet colormap on it and shows the result:

% We need an input image. (can be grayscale or color)
img_in = im2uint8(mat2gray(peaks(500)));

% Apply the colormap
%img_color2 = ind2rgb(img_in, jet(256));
img_color = cv.applyColorMap(img_in, 'Jet');

% Show the result
imshow(img_color)

Example

cmaps = {'Autumn', 'Bone', 'Jet', 'Winter', 'Rainbow', 'Ocean', ...
    'Summer', 'Spring', 'Cool', 'Hsv', 'Pink', 'Hot', 'Parula'};
img = cell2mat(cellfun(@(cmap) ...
    cv.applyColorMap(repmat(uint8(0:255), 20, 1), cmap), cmaps(:), ...
    'UniformOutput',false));
image(img)
set(gca, 'YTick', 10:20:20*numel(cmaps), 'YTickLabel',cmaps)
title('Colormaps')
See also