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