How to mimic the colormap of a RGB image?

4 views (last 30 days)
Hello everybody,
I have the following picture from with I would like to mimic the colormap (one color per horizontal plane) in order to use as colormap elsewhere. Any suggestion?
Thanks for your contributions,
Santi

Accepted Answer

Thorsten
Thorsten on 10 Mar 2017
I = im2double(imread('../../Downloads/Colormap.png')); % read and convert to double
I = I(:,1,:); % we just need each color once, so we just need one column
cmap = reshape(I, [], 3); % convert to N x 3 color map format

More Answers (2)

Adam
Adam on 10 Mar 2017
Should be easy enough to create in
doc colormapeditor
or just in code using linspace if you know the values. Or if you can just read in the image you can use that if you convert it to the right nx3 format, though the image you showed appears to just be cut out from somewhere so includes bits of white around the edge rather than purely the colourmap so reading the image in and using that would prove tricky. Reading the image in and manually creating the colourmap would not be too hard though. Depends how accurately you want it to be replicated.

Image Analyst
Image Analyst on 10 Mar 2017
"I would like to mimic the colormap (one color per horizontal plane) in order to use as colormap" <==== What's wrong with simply doing:
% Define some number of rows, like 256 or whatever - what you called the number of "horizontal planes"
numberOfRows = 256;
myColorMap = jet(numberOfRows);
Now you have the colormap and you can use it wherever and however you want.

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!