Colormap, how to get the color of the sea

조회 수: 11 (최근 30일)
Xin
Xin 2016년 12월 1일
편집: DGM 2023년 1월 3일
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

채택된 답변

Image Analyst
Image Analyst 2016년 12월 1일
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
noor
noor 2023년 1월 3일
what does the function numColors do?
DGM
DGM 2023년 1월 3일
편집: DGM 2023년 1월 3일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by