Be the first to rate this file! 17 downloads (last 30 days) File Size: 6.06 KB File ID: #22325

rgb2name

by matt dash

 

04 Dec 2008

Code covered by BSD License  

Names a color based on its RGB-triple colorspec. Knows over 400 color names.

Download Now | Watch this File

File Information
Description

RGB2NAME returns a string containing the name of the input RGB triple. (Or a cell array of strings if an array is input.) This is a "brute force" approach that contains a large list of colors and their names, and uses a very simple nearest neighbor search to find the named color that is closest to the input color.

The included list has more than 400 color names, and it performs pretty well. There are a few regions of the color space where it isn't great, particularly with low-saturation colors.

This is mostly just for kicks, but I made it for a GUI that needs to ask the user about unnamed hg objects, so instead i can describe them to the user by color. Like "...the graph with the light red and very dark green lines..."

There is also a demo included (requires java) that names colors selected by the user in a jcolorchooser.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements R2007a or later, or requires a bsxfun replacement. Demo requires java to be enabled, but main function does not.
Zip File Content  
Other Files rgb2name.m,
rgb2namedemo.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.
Tag Activity for this File
Tag Applied By Date/Time
rgb Cristina McIntire 05 Dec 2008 14:47:47
color Cristina McIntire 05 Dec 2008 14:47:47
cell array Cristina McIntire 05 Dec 2008 14:47:47
color matt dash 05 Dec 2008 14:47:54
rgb matt dash 05 Dec 2008 14:47:54
color name matt dash 05 Dec 2008 14:47:54
name matt dash 05 Dec 2008 14:47:54
colormap matt dash 05 Dec 2008 14:47:54
colorspec matt dash 05 Dec 2008 14:47:54
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com