BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Anyone any thoughts/references on how to order the 64 colors in this image so that a group of lines draw in colors picked from an adjacent set of values from the ordered set will stand a reasonable chance of being discernible?

That is: if you pick (say) 12 adjacent values from anywhere in the ordered set; they'll likely contrast fairly well.

Someone must have done this, but I haven't found the right set of keywords yet. (I'm fairly particular about this set of colors; unless someone knows of a better set?)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re: [OT] Ordering colors
by choroba (Cardinal) on May 05, 2015 at 13:40 UTC
    My colour-blind friend gave me the following link once: Paul Tol's notes. Maybe it can help you, too.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Thankyou choroba. It never ceases to amaze me the quality of the information that questions to this site garner.

      Not only is that link spot on relevance for my purpose; the quality and authority of the information is beyond doubt. Even the pdfs (technotes) are concise, understandable and come with clear demonstrations of the solutions being presented. (Sorry to gush; but I'm truly stunned!)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re: Ordering colors for contrast (luma)
by Anonymous Monk on May 05, 2015 at 11:22 UTC

    I had this in my notes, so I'd calculate the luma and sort by luma

    You probably want to shift hue, but not saturation or value. So, convert your RGB value into HSV, add 180 degrees to H (modulo 360 +degrees of course), and convert back to RGB. function contrastingColor(color) { return (luma(color) >= 165) ? '000' : 'fff'; } function luma(color) // color can be a hx string or an array of RGB va +lues 0-255 { var rgb = (typeof color === 'string') ? hexToRGBArray(color) : col +or; return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]); +// SMPTE C, Rec. 709 weightings } http://juicystudio.com/article/luminositycontrastratioalgorithm.php http://www.splitbrain.org/blog/2008-09/18-calculating_color_contrast_w +ith_php http://stackoverflow.com/questions/301869/how-to-find-good-looking-fon +t-color-if-background-color-is-known http://search.cpan.org/~ian/Color-Scheme-1.02/lib/Color/Scheme.pm http://colorschemedesigner.com/ http://stackoverflow.com/questions/97646/how-do-i-determine-darker +-or-lighter-color-variant-of-a-given-color http://stackoverflow.com/questions/635022/calculating-contrasting- +colours-in-javascript http://stackoverflow.com/questions/141855/programmatically-lighten +-a-color http://www.mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-mod +el-conversion-algorithms-in-javascript http://www.lighthouse.org/accessibility/effective-color-contrast http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight- +search-terms-with-jquery/ https://developer.mozilla.org/en/DOM/window.getComputedStyle

      I sorted them using your luma function and got this which doesn't have the effect I'm looking for. It seems to concentrate similar colors together. Eg. the yellows and light silver at the far end, the blues and greens at the near end, the reds and pinks in a couple of bunches.

      I'm slowly working my way the the links you posted, but they seem to be mostly about picking one color to contrast with one other color; and I'm stuck to think of a way to use that order 64 colors for my purpose.

      I approaching the conclusion that it might be an NP problem: basically, like trying to arrange the numbers 1 through 64 such that you maximise the sum of the differences between adjacent numbers.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

        Ha, there are four lumas, ( 2.996, 3.7112 , 2.7834, 3.4986, ) ... yaytk

      Luma contrast is not enough. The primate brain (including the human brain) processes luma and color in 2 parallel systems. While this does have an efficiency advantage, it leaves us sessepible to visual artifacts caused by conflicting pattern analysis results from the 2 systems.

Re: [OT] Ordering colors
by erix (Prior) on May 05, 2015 at 11:50 UTC

    Not an answer for this particular colorset (and assuming that you are trying to color value-ranges):

    Excel knows how to color value-ranges (and does it nicely/effectively, I think); perhaps it's possible to use those colors, gleaned from the produced spreadsheet-xml.

    (I haven't done it but often thought that it should be doable.)

      Sounds like a possibility, but I don't have Excel. (Any chance you could post something?)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re: [OT] Ordering colors
by jeffa (Bishop) on May 05, 2015 at 19:22 UTC

    Problem solved, but perhaps this little CGI script will be of service to you. It uses Color::Spectrum to generate a 12 cell, one row table whose cells range from the starting color to the ending color.

    use strict; use warnings; use CGI; use HTML::Template; use Color::Spectrum qw(generate); my $cgi = CGI->new; my $tmpl = HTML::Template->new( filehandle => \*DATA, associate => $cg +i ); my $vars = $cgi->Vars; if ($vars->{go}) { my @colors = map { c => $_ }, generate( 12, @{$vars}{qw(start end) +} ); $tmpl->param( colors => \@colors ); } print $cgi->header, $tmpl->output; __DATA__ <form method="post"> Color 1: <input type="text" name="start" value="#" /><br /> Color 2: <input type="text" name="end" value="#" /><br /> <input type="submit" name="go" /> </form> <tmpl_if go> <table width="100%"> <tr> <tmpl_loop colors><td bgcolor="<tmpl_var c>"><tmpl_var c></td></tmpl_l +oop> </tr> </table> </tmpl_if>

    You might be able to use this to generate your candidate ranges to see if they work or not.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)