Colormap, how to get the color of the sea

6 views (last 30 days)
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

Accepted Answer

Image Analyst
Image Analyst on 1 Dec 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 Comments
noor
noor on 3 Jan 2023
what does the function numColors do?
DGM
DGM on 3 Jan 2023
Edited: DGM on 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

Sign in to comment.

More Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!