How to write the colormap code for the colorbar presented in the figure?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Naresh Pati
il 22 Dic 2018
Modificato: David Goodmanson
il 22 Dic 2018
How to write the colormap code for the colorbar presented in the figure?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199608/image.jpeg)
1 Commento
Risposta accettata
David Goodmanson
il 22 Dic 2018
Modificato: David Goodmanson
il 22 Dic 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199612/image.jpeg)
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Colormaps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!