Code covered by the BSD License  

Highlights from
RGB.m

Be the first to rate this file! 16 Downloads (last 30 days) File Size: 2.47 KB File ID: #24015

RGB.m

by Phillip M. Feldman

 

06 May 2009 (Updated 17 May 2009)

RGB() converts a color index or name into an RGB triple with real-valued components in [0,1].

| Watch this File

File Information
Description

OVERVIEW

The Matlab function RGB() converts a color index (whole number from 1-21), English name of a color (string), or RGB triple with whole number components in {0, 1, ..., 255} into an RGB triple with real-valued components in [0,1]. RGB() allows the user to access a set of 21 colors via their common English names. For eight of these colors that have more than one common name, the program accepts alternative names, reducing the memory burden on the user.

INPUTS

- index_or_name can be a color index (whole number from 1-21), a string containing the name of a color in lower case, an RGB triple with elements in [0,1], or an RGB triple with elements in [0,255]. Note that some colors have more than one name, in which case any of these may be used. See the code for the list of color names.

OUTPUTS

- RGB is a length-3 vector of RGB components that can be used as a color specifier with any of the Matlab graphics functions.

If the input is an RGB triple with elements in [0,1], it is returned to
the calling program without modification.

If the input is an RGB triple with elements in [0,255], it is scaled by
1/255 and then returned.

If the input is a color index (1-21), it is converted to an RGB triple
via direct table lookup.

If the input is the name of a color, a search is done to find a matching name, and the corresponding RGB triple is returned.

MATLAB release MATLAB 7.7 (R2008b)
Other requirements RGB.m depends on cell2num.m and lookup.m.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
13 May 2009

Split out files in .zip as separate items.

17 May 2009

Added information on dependencies.

Tag Activity for this File
Tag Applied By Date/Time
color management Phillip M. Feldman 06 May 2009 15:48:45
colors Phillip M. Feldman 06 May 2009 15:48:45
rgb Phillip M. Feldman 06 May 2009 15:48:45

Contact us at files@mathworks.com