makergb

버전 3.0.0.1 (4.95 KB) 작성자: Andres
multidimensional numeric RGB color array from mixed inputs
다운로드 수: 38
업데이트 날짜: 2021/10/21

라이선스 보기

makergb creates a numeric RGB color array from different (mixed) input elements, including 3- and 6-digit hexadecimal color codes and pre-defined color names.
makergb can handle multidimensional inputs and returns the RGB triplet between 0 and 1 along the highest dimension. It returns a (customizable) default value for missing or non-interpretable input elements.
Pre-defined color names comprise short and long names from Matlab's ColorSpec plus a few extensions including the current and previous Matlab default colors (overall 32 different colors, see image). The emphasis is not on exhaustive color name conversion; for that purpose see various other file exchange submissions, most notably https://de.mathworks.com/matlabcentral/fileexchange/48155-convert-between-rgb-and-color-names
Examples:
string input
>> rgb = makergb("orange")
rgb =
1.0000 0.5000 0
>> rgb = makergb("m"+(1:4)) % Matlab's first four default colors
rgb =
0 0.4470 0.7410
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
0.4940 0.1840 0.5560
char or cell array input
>> rgb = makergb(char('red','green','blue'))
rgb =
1 0 0
0 1 0
0 0 1
>> rgb = makergb({'red','green','blue','purple'})
rgb =
1 0 0
0 1 0
0 0 1
0.5 0 0.5
multidimensional input
>> rgb = makergb(["r","g";"y","k"])
rgb(:,:,1) = rgb(:,:,2) = rgb(:,:,3) =
1 0 0 1 0 0
1 0 1 0 0 0
mixed input color representations with a missing value, default set to white
>> [rgb,tfi] = makergb({'r',[0 1 0],'0000ff',"#F0F",[]}, 'w')
rgb =
1 0 0
0 1 0
0 0 1
1 0 1
1 1 1
tfi =
1×5 logical array
1 1 1 1 0

인용 양식

Andres (2024). makergb (https://www.mathworks.com/matlabcentral/fileexchange/95168-makergb), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2021a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
3.0.0.1

updated picture

3.0.0

added current and previous matlab default colors

1.0.0