How to write the colormap code for the colorbar presented in the figure?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Naresh Pati
am 22 Dez. 2018
Bearbeitet: David Goodmanson
am 22 Dez. 2018
How to write the colormap code for the colorbar presented in the figure?
1 Kommentar
Akzeptierte Antwort
David Goodmanson
am 22 Dez. 2018
Bearbeitet: David Goodmanson
am 22 Dez. 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!