How to mimic the colormap of a RGB image?

2 visualizaciones (últimos 30 días)
Santi
Santi el 10 de Mzo. de 2017
Respondida: Image Analyst el 10 de Mzo. de 2017
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

Respuesta aceptada

Thorsten
Thorsten el 10 de Mzo. de 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

Más respuestas (2)

Adam
Adam el 10 de Mzo. de 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 el 10 de Mzo. de 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.

Categorías

Más información sobre Red en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by