Generate maximally perceptually-distinct colors
by Tim Holy
14 Dec 2010
(Updated 07 Feb 2011)
Choose a set of n colors that can be readily distinguished from each other
|
Watch this File
|
| File Information |
| Description |
When plotting a set of lines, you may want to distinguish them by color. By default, Matlab chooses a small set of colors and cycles among them, and so if you have more than a few lines there will be confusion about which line is which. To fix this problem, one would want to be able to pick a much larger set of distinct colors, where the number of colors equals or exceeds the number of lines you want to plot. Because our ability to distinguish among colors has limits, one should choose these colors to be "maximally perceptually distinguishable."
This function generates a set of colors which are distinguishable by reference to the "Lab" color space, which more closely matches human color perception than RGB. Given an initial large list of possible colors, it iteratively chooses the entry in the list that is farthest (in Lab space) from all previously-chosen entries. |
| Acknowledgements |
The author wishes to acknowledge the following in the creation of this submission:
varycolor, Colorspace Transformations
This submission has inspired the following:
Explore Experimental Data
|
| Required Products |
Image Processing Toolbox
|
| MATLAB release |
MATLAB 7.10 (2010a)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 14 Dec 2010 |
I have added the option for the user to supply a function handle to any desired colorspace conversion function. One application is to use the file exchange's "colorspace" set of tools. In this case, you no longer need the image processing toolbox.
|
| 07 Feb 2011 |
As suggested by Il, I added the ability to avoid multiple background colors. |
|
Contact us at files@mathworks.com