How to mimic the colormap of a RGB image?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Thorsten
2017-3-10
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
更多回答(2 个)
Adam
2017-3-10
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.
0 个评论
Image Analyst
2017-3-10
"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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!