Re: [R] measuring distances between colours?

2013-06-02 Thread Kevin Wright
Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Michael Friendly Sent: Saturday, June 01, 2013 11:33 AM To: John Fox Cc: 'r-help'; 'Martin Maechler' Subject: Re: [R] measuring distances between colours? Just a quick note: The following

Re: [R] measuring distances between colours?

2013-06-02 Thread John Fox
10:43 AM To: John Fox Cc: r-help; Michael Friendly; Martin Maechler Subject: Re: [R] measuring distances between colours? Sorry about the bug. How embarrassing. Especially because I've learned over the years to trust my gut feelings when something doesn't feel quite right, and when I

Re: [R] measuring distances between colours?

2013-06-01 Thread Michael Friendly
] measuring distances between colours? Thanks for the discussion. I've also wanted to be able to find nearest colors. I took the code and comments in this thread and simplified the function even further. (Personally, I think using closures results in Rube-Goldberg code. YMMV.) The first example

Re: [R] measuring distances between colours?

2013-06-01 Thread John Fox
Hi Michael, Thanks for the Wikipedia tip -- I'd looked there but didn't find this article. The article explains that the Lab colour space was formulated to provide uniform perceptual differences between colours, with a JND of approximately of 2.3. Ken Knoblauch made a similar point. The article

Re: [R] measuring distances between colours?

2013-06-01 Thread Ken Knoblauch
Hi John, Out of curiosity and if it is not much trouble, I would be curious if Luv worked any better than Lab. I think that Luv is supposed to be preferred for monitors and Lab for surfaces but they are generally pretty similar. Best, Ken Sent from my iPhone ___ Ken Knoblauch Inserm U846

Re: [R] measuring distances between colours?

2013-06-01 Thread John Fox
: Saturday, June 01, 2013 11:33 AM To: John Fox Cc: 'r-help'; 'Martin Maechler' Subject: Re: [R] measuring distances between colours? Just a quick note: The following two versions of your function don't give the same results. I'm not sure why, and also not sure why the criterion for 'near

Re: [R] measuring distances between colours?

2013-06-01 Thread John Fox
-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Ken Knoblauch Sent: Saturday, June 01, 2013 12:18 PM To: John Fox Cc: r-help@r-project.org; Michael Friendly; Martin Maechler Subject: Re: [R] measuring distances between colours? Hi John, Out of curiosity

Re: [R] measuring distances between colours?

2013-06-01 Thread Michael Friendly
Hi John I agree that the Lab representation is the best so far for the goal of perceptually similar colors, and the approximate JND of 2.3 on the distance scale in this space is a useful, non-arbitrary criterion. FWIW, your demo might better show the hex and color names adjacently, for

Re: [R] measuring distances between colours?

2013-06-01 Thread Ken Knoblauch
: Saturday, June 01, 2013 12:18 PM To: John Fox Cc: r-help@r-project.org; Michael Friendly; Martin Maechler Subject: Re: [R] measuring distances between colours? Hi John, Out of curiosity and if it is not much trouble, I would be curious if Luv worked any better than Lab. I think that Luv

Re: [R] measuring distances between colours?

2013-05-31 Thread Martin Maechler
] measuring distances between colours? Dear John, John Fox j...@mcmaster.ca on Thu, 30 May 2013 08:13:19 -0400 writes: Dear r-helpers, I'm interested in locating the named colour that's closest to an arbitrary RGB colour. Hmm, maybe I was not really

Re: [R] measuring distances between colours?

2013-05-31 Thread Martin Maechler
John Fox j...@mcmaster.ca on Thu, 30 May 2013 17:14:06 -0400 writes: Dear all, My thanks to everyone who addressed my question. I've incorporated Eik Vettorazzi's suggestion for improved conversion of hexadecimal RGB colours to decimal numbers, and Martin

Re: [R] measuring distances between colours?

2013-05-31 Thread Michael Friendly
Hi John This has been an interesting discussion. Though you have a solution for your needs, you might be interested in this javascript implementation that allows you to visually compare color distances in various color spaces http://stevehanov.ca/blog/index.php?id=116 And, all the theory of

Re: [R] measuring distances between colours?

2013-05-31 Thread Kevin Wright
Thanks for the discussion. I've also wanted to be able to find nearest colors. I took the code and comments in this thread and simplified the function even further. (Personally, I think using closures results in Rube-Goldberg code. YMMV.) The first example below is what I use for 'group'

Re: [R] measuring distances between colours?

2013-05-31 Thread John Fox
. Best, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Kevin Wright Sent: Friday, May 31, 2013 3:39 PM To: Martin Maechler Cc: r-help; John Fox Subject: Re: [R] measuring distances between colours? Thanks

[R] measuring distances between colours?

2013-05-30 Thread John Fox
Dear r-helpers, I'm interested in locating the named colour that's closest to an arbitrary RGB colour. The best that I've been able to come up is the following, which uses HSV colours for the comparison: r2c - function(){ hexnumerals - 0:15 names(hexnumerals) - c(0:9, LETTERS[1:6])

Re: [R] measuring distances between colours?

2013-05-30 Thread Jim Lemon
On 05/30/2013 10:13 PM, John Fox wrote: Dear r-helpers, I'm interested in locating the named colour that's closest to an arbitrary RGB colour. The best that I've been able to come up is the following, which uses HSV colours for the comparison: r2c- function(){ hexnumerals- 0:15

Re: [R] measuring distances between colours?

2013-05-30 Thread Ken Knoblauch
John Fox jfox at mcmaster.ca writes: I'm interested in locating the named colour that's closest to an arbitrary RGB colour. The best that I've been able to come up is the following, which uses HSV colours for the comparison: r2c - function(){ hexnumerals - 0:15 names(hexnumerals)

Re: [R] measuring distances between colours?

2013-05-30 Thread John Fox
Hi Jim, Thanks for this. Ben's function makes comparisons in the RGB rather than the HSV colour space; works on the decimal rather than hex representation of colours; applies to a single colour rather than a vector; recomputes the CSV representation of the named colours each time it's called

Re: [R] measuring distances between colours?

2013-05-30 Thread John Fox
Dear Ken, Yes, that's the paper I was trying to remember, along with the associated spaces. I'll probably get a better solution using the colorspace package. Thanks, John On Thu, 30 May 2013 12:36:11 + Ken Knoblauch ken.knobla...@inserm.fr wrote: John Fox jfox at mcmaster.ca writes:

Re: [R] measuring distances between colours?

2013-05-30 Thread Martin Maechler
Dear John, John Fox j...@mcmaster.ca on Thu, 30 May 2013 08:13:19 -0400 writes: Dear r-helpers, I'm interested in locating the named colour that's closest to an arbitrary RGB colour. Hmm, maybe I was not really marketing well enough what I had added for R 3.0.0 :

Re: [R] measuring distances between colours?

2013-05-30 Thread Martin Maechler
John Fox j...@mcmaster.ca on Thu, 30 May 2013 08:51:10 -0400 writes: Dear Ken, Yes, that's the paper I was trying to remember, along with the associated spaces. I'll probably get a better solution using the colorspace package. I'm not sure. Some of the colorspace package

Re: [R] measuring distances between colours?

2013-05-30 Thread Eik Vettorazzi
Hi John, i would propose a one-liner for the hexcode transformation: hex2dec-function(hexnums)sapply(strtoi(hexnums,16L),function(x)x%/%256^(2:0)%%256) #instead of hexnumerals - 0:15 names(hexnumerals) - c(0:9, LETTERS[1:6]) hex2decimal - function(hexnums){ hexnums - strsplit(hexnums, )

Re: [R] measuring distances between colours?

2013-05-30 Thread John Fox
Dear Martin, -Original Message- From: Martin Maechler [mailto:maech...@stat.math.ethz.ch] Sent: Thursday, May 30, 2013 9:18 AM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] measuring distances between colours? Dear John, John Fox j...@mcmaster.ca on Thu, 30 May

Re: [R] measuring distances between colours?

2013-05-30 Thread John Fox
- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Eik Vettorazzi Sent: Thursday, May 30, 2013 9:33 AM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] measuring distances between colours? Hi John, i would propose a one-liner for the hexcode

Re: [R] measuring distances between colours?

2013-05-30 Thread John Fox
...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of John Fox Sent: Thursday, May 30, 2013 8:13 AM To: r-help@r-project.org Subject: [R] measuring distances between colours? Dear r-helpers, I'm interested in locating the named colour that's closest to an arbitrary RGB colour