Maximum Perceptual Difference Qualitative Colormap Generator

Version 4.0.1 (46,3 KB) von Moreno, M.
Generates a qualitative palette with maximum color differences (CIE 1931 or CIEDE 2000). TSP 2-opt algorithm for 'max/min' contrast sorting.
20 Downloads
Aktualisiert 7. Jul 2024

Lizenz anzeigen

Description
[COL,DMIN,~] = truecol(N,INI,LAB,IMAX,ORD): Returns the 'N'-color sample 'COL' that achieves maximum perceptual differences between entries and the minimum color distance 'DMIN', as per the inputs:
N: Color sample size if scalar, or initial color matrix to optimize (N-by-3). Negative 'N' for colorblind schemes (-12<=N<=-1). Pre-stored cases for 1<=N<=23 and specific 'INI' values.
INI: Initial sample of colors (to exclude): Empty, a M-by-3 matrix, or 'b'/'k', 'w' and 'bw'/'kw' for black/white. If NaN, the search settings are override, and only distances and plots are calculated.
LAB: By default, CIE 1931 color space. If set to 0 or false, CIEDE 2000 standard.
IMAX: Maximum iterations (scalar), cycles/iterations (2-element vector), or cycles/iterations/refinement iterations (NaN or 3-element vector, exploratory mode)
ORD: Sorting order: 1 (maximum contrast, set as default), -1 (minimum contrast), 0 (random), NaN (unsorted). If not NaN, the color array starts with the bluest color, evolving in the reddest direction.
Passing NO OUTPUT arguments queries the generation of MULTIPLE PLOTS. If THREE OUTPUT parameters are queried, a SMALL FIGURE containing the final color palette is produced. A database with optimized CIEDE 2000 and CIE 1931 colors is provided for 0<'N'<24, for 'black', 'white' or both 'black' and 'white' initial colors. Also, 12 distinct colorblind palettes are included if the function is called for -12<='N'<=-1. The parameter 'IMAX' passes the sorting order 'ORD' if the queried sample is stored in 'COLORBASE' for 4 input arguments. Therefore, quick ways to run the function for these cases are:
[x,d,~] = truecol(8,'bw',0); % CIEDE 2000 -bw palette (8)
[x,d,~] = truecol(6,[0,0,0]); % CIELAB 1931 -b palette (6)
[x,d,~] = truecol(9,'',0,-1); % CIEDE2000 low contrast (9)
[x,d,~] = truecol(-2); % Okabe-Ito (-b) palette (7)
The algorithm uses a MINIMAX routine to optimize the color space, and a TSP with 2-Opt to sort the final color matrix. The iteration of the color sample between colorblind, CIELAB and CIEDE standards is highly encouraged, as there is no unique method for optimal color selection. The user is kindly referred to the description of the function inputs or to the comments of the code for further assistance. A standard way of running this function for new samples is, for example:
% Exploratory mode to find a new CIEDE color palette
[x,d,~] = truecol(8,[0,0,0;1,1,1;1,1,0],0,[1e2,1e2,1e4],-1);
% Visualise a given sample (i.e, Tol's High Contrast)
col = [255,255,255;221,170,51;187,85,102;0,68,136;0,0,0]/255;
truecol(col,NaN);
% Sort an existing sample for minimum contrast
[x,d,~] = truecol(truecol(-3),NaN,0,0,-1); % R-Default
Examples
MathWorks Palette
Okabe-Ito palette
Tsitsulin palette
CIEDE2000 palette
Tol (bright) palette
Enjoy!
Miguel Moreno, July 2024

Zitieren als

Moreno, M. (2024). Maximum Perceptual Difference Qualitative Colormap Generator (https://www.mathworks.com/matlabcentral/fileexchange/168721-maximum-perceptual-difference-qualitative-colormap-generator), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2024a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
4.0.1

- Use of INI to override search settings if NaN is passed (useful to evaluate distances)
- Last colorblind palette replaced by a high-contrast sample from Tol, P.'s website
- Re-sorting of pre-existing palettes with double function call, in examples

4.0.0

- Added 12 colorblind-friendly palettes when N<0 (okabe, Tol, R, etc.)
- Automatic figure without flag calling 0 (verbose) or 3 (terse) outputs
- Simplified function's description text, and cleared empty outputs

3.0.11

- Removed self-distance calculations affecting initial samples
- Quick run mode skipping iterations for pre-stored cases (most frequent)
- Enhanced descriptive text

3.0.10

- Quick exit for cases that are affine to pre-calculated samples
- Exploratory mode accessible passing a 3-element vector in IMAX
- Overall check for robustness and modification of some defaults

3.0.9

- Typo in the 'exploratory' mode using NaN
- Robustness for user inputs
- Small corrections for speed
- Re-formatted plots to be more aesthetic
- Thoroughly commented the code

3.0.8

- Speed boost in subfunction switching if/else by switch
- Marker size and line width enhancement in figures

3.0.7

- Enhanced function descriptive text
- Added systematic sorting to avoid inconsistent order between different runs

3.0.6

- Typo where an important line was commented

3.0.5

- Included 'demo' file in main body if the flag FIG is set to one at the beginning of the function. Expanded description text with my recommendations of use.

3.0.4

- Changed order of input parameters
- Added sorting order from MISC to input parameters
- Adjusted DEMO function to account for changes
- Better descriptive text and examples

3.0.3

- Changed image of the post
- Typo in calling the demo function by its old name

3.0.2

- Output name resolution for figure generation in the 'NaN' search cases.

3.0.1

- Added small subfunction in demo routine
- Added plot generation in main function with a third empty output

3.0.0

- Included CIE1931 metric
- Generalised TSP code
- Optimised subfunctions
- Removed miscellaneous
- Simplified input arguments
- Added a demo file

2.0.1

- Typo in struct field 'opt.figure'
- Commented an alternative approach
- Changed title and summary slightly

2.0.0

- Corrected a typo in the initial distance calculation
- General tweaks to improve performance
- Added a database of precalculated cases
- Sorted final output for max/min contrast
- Enabled control of algorithm and outputs
- Detailed code description

1.0.0