필터 지우기
필터 지우기

How to write the colormap code for the colorbar presented in the figure?

조회 수: 1 (최근 30일)
How to write the colormap code for the colorbar presented in the figure?

채택된 답변

David Goodmanson
David Goodmanson 2018년 12월 22일
편집: David Goodmanson 2018년 12월 22일
Hi Naresh,
Even if all you have is the jpg you can still make progess. I called the the jpg image A, and
figure(1)
image(A)
Then you can use the data cursor option to take a look at the the top and bottom ends of the colorbar. I found that the colorbar runs from pixels y = 7 to 200 along a typical line x = 352. For reasons I can never quite remember you need to reverse the coordinates to find
cm = squeeze(A(7:200,352,:));
which produces a colormap matrix of size 194 x 3. Then
x = 1:size(cm,1);
figure(2)
plot(x,cm(:,1),'r',x,cm(:,2),'g',x,cm(:,3),'b')
shows the following:
This does not appear to be a named Matlab colormap. As you can see, it starts out red, then after a not-so-obvious percentage of the total horizontal span it becomes r+g = yellow, then drops down to black and ends up white.
(Since the pixels were taken from top to bottom, the colormap cm should actually be flipped top to bottom. Then the plot above would be flipped from left to right and low index values would correspond to the bottom end of the colorbar).
The fact that there are 194 points doesn't necessarly mean anything. Matlab often scales the data between colormap end points, in which case this could be redone with any number of points as long as there are enough to make the colorbar colors look continuous (see 'caxis'). It's the percentage of the horizontal span at the break points that matters.

추가 답변 (0개)

카테고리

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