필터 지우기
필터 지우기

How to mimic the colormap of a RGB image?

조회 수: 2 (최근 30일)
Santi
Santi 2017년 3월 10일
답변: Image Analyst 2017년 3월 10일
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

채택된 답변

Thorsten
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
  댓글 수: 1
Santi
Santi 2017년 3월 10일
Very useful, thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

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

Image Analyst
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.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by