Code covered by the BSD License  

Highlights from
RGB triple of color name, version 2

5.0

5.0 | 9 ratings Rate this file 106 Downloads (last 30 days) File Size: 4.46 KB File ID: #24497
image thumbnail

RGB triple of color name, version 2

by Kristjan Jonasson

 

20 Jun 2009 (Updated 05 Jul 2009)

Returns a Matlab RGB color specifier corresponding to a given color name (139 colors supported).

| Watch this File

File Information
Description

RGB = RGB('COLORNAME') returns the red-green-blue triple corresponding to the color named COLORNAME by the CSS3 proposed standard [1], which contains 139 different colors (an rgb triple is a 1x3 vector of numbers between 0 and 1). The color names are the ones accepted by almost all web browsers, for example Brown, DarkRed, SlateGray.

RGB CHART creates a figure window showing all the available colors with their names.

COLORNAME = RGB(r,g,b) and COLORNAME = RGB([r,g,b]) both find the name of the color with the triple that is closest to [r,b,g] (measured by sum of squares).

EXAMPLES
  c = rgb('DarkRed') gives c = [0.5430 0 0]
  c = rgb('Green') gives c = [0 0.5 0]
  plot(x,y,'color',rgb('orange')) plots an orange line through x and y
  rgb chart shows all the colors
  cnam = rgb(0.8,0.3,0.3) gives cnam = 'IndianRed'

REFERENCES
[1] "CSS Color module level 3", W3C (World Wide Web Consortium) working draft 21 July 2008, http://www.w3.org/TR/css3-color.
[2] "Web colors", http://en.wikipedia.org/wiki/Web_colors

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
22 Jun 2009 us

excellent in-depth help including many references...
easily expandable look-up table engine...
certainly very useful for color-freaks...
us

08 Jul 2009 Husam Aldahiyat

Amaaazing!

19 Aug 2009 Sabine  
27 Aug 2009 K R

this is so simple and brilliant!!! What a massive time-saver and figure-improver!! A million thanks!!

04 Feb 2010 Richard Crozier

very handy, thanks!

11 Jun 2010 April Warnock

This is great! Thanks so much!

30 Jun 2010 Darwin@cal Chang

Great job!

17 Feb 2011 Ryan Stanley

This is a great tool however I am having a few issues. When I use your example code:

cnam = rgb(0.8,0.3,0.3)

Matlab returns:

??? Error using ==> rgb
Too many input arguments.

Any ideas?

21 Apr 2011 Feda  
22 Apr 2011 Wafa BEN RHOUMA  
Please login to add a comment or rating.
Updates
05 Jul 2009

VERSION 2 allows finding color name given rgb triple.

Tag Activity for this File
Tag Applied By Date/Time
color Kristjan Jonasson 22 Jun 2009 11:14:36
rgb Kristjan Jonasson 22 Jun 2009 11:14:37
colour Kristjan Jonasson 22 Jun 2009 11:14:37
color name Kristjan Jonasson 22 Jun 2009 11:14:37
color Dirk 09 Aug 2011 11:26:27
color name Dirk 09 Aug 2011 11:26:30
color Ayelet 24 Nov 2011 07:42:42
color sima nang 17 Dec 2011 02:00:20

Contact us at files@mathworks.com