Colormap, how to get the color of the sea

12 vues (au cours des 30 derniers jours)
Xin
Xin le 1 Déc 2016
Modifié(e) : DGM le 3 Jan 2023
This is an interesting question to me. I wanted to create a nice colormap with very smooth and gradual transition from white to sea blue. I tried to do it manually in colormap but it does not work out very well. Anybody who has explored this, or know some developed colormap?
Many thanks

Réponse acceptée

Image Analyst
Image Analyst le 1 Déc 2016
Try a program where you can easily get the RGB values of some color of blue that you like, like (r,g,b) = (rBlue, gBlue, bBlue). Then use linspace().
numColors = 256; % Good value for 24/32 bit displays.
oceanRed = 15;
oceanGreen = 127;
oceanBlue = 230;
myColorMap = [linspace(oceanRed, 255, numColors)'/255,...
linspace(oceanGreen, 255, numColors)'/255,...
linspace(oceanBlue, 255, numColors)'/255]
imshow('cameraman.tif');
colormap(gca, myColorMap);
colorbar
  2 commentaires
noor
noor le 3 Jan 2023
what does the function numColors do?
DGM
DGM le 3 Jan 2023
Modifié(e) : DGM le 3 Jan 2023
The variable numColors specifies the number of tuples (rows) in the colormap. It's easy enough to test.
numColors = 5; % change the value and see what happens
oceanRed = 15;
oceanGreen = 127;
oceanBlue = 230;
myColorMap = [linspace(oceanRed, 255, numColors)'/255,...
linspace(oceanGreen, 255, numColors)'/255,...
linspace(oceanBlue, 255, numColors)'/255]
myColorMap = 5×3
0.0588 0.4980 0.9020 0.2941 0.6235 0.9265 0.5294 0.7490 0.9510 0.7647 0.8745 0.9755 1.0000 1.0000 1.0000

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by