Azzera filtri
Azzera filtri

How to mimic the colormap of a RGB image?

1 visualizzazione (ultimi 30 giorni)
Santi
Santi il 10 Mar 2017
Risposto: Image Analyst il 10 Mar 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

Risposta accettata

Thorsten
Thorsten il 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

Più risposte (2)

Adam
Adam il 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 il 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.

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by