Re: Color closest to color

2014-06-17 Thread Graham Cox
On 18 Jun 2014, at 12:04 am, Maxthon Chan wrote: > moronically :) monotonically? But maybe both are true! --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contac

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
Once again, you don’t need to perform the square root before comparing. It is a waste of processor resource and not doing ti will not throw off comparison (since mathematically, square root function is moronically increasing.) On Jun 17, 2014, at 22:02, Jonathan Taylor wrote: > Thanks everyone

Re: Color closest to color

2014-06-17 Thread edward taffel
you may wish to look up ‘Delta E’. [what has this to do w/ cocoa?] On Jun 17, 2014, at 9:29 AM, Maxthon Chan wrote: > Alternatively I have an idea based on HSB colours: difference in hue in > radians raised to 4th power (or 6th) plus squared Euclidean distance of > saturation and brightness.

Re: Color closest to color

2014-06-17 Thread Jonathan Taylor
Thanks everyone. I had thought there might be a pre-existing API that would do this (I was half expecting to find a method defined for the NSColorList class...), but I will implement the euclidean distance test myself... Cheers Jonny. On 17 Jun 2014, at 12:43, Maxthon Chan wrote: > One easy-to

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
Alternatively I have an idea based on HSB colours: difference in hue in radians raised to 4th power (or 6th) plus squared Euclidean distance of saturation and brightness. On Jun 17, 2014, at 21:22, Torsten Curdt wrote: > RGB is not perceptually uniform, hence the Euclidean distance is not qui

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
I know, it is just sqared Euclidean distance is simplest to calculate. Sure you can, for example, add coefficients to the formula, to adjust. On Jun 17, 2014, at 21:22, Torsten Curdt wrote: > RGB is not perceptually uniform, hence the Euclidean distance is not quite > right. > Wikipedia and St

Re: Color closest to color

2014-06-17 Thread Torsten Curdt
RGB is not perceptually uniform, hence the Euclidean distance is not quite right. Wikipedia and Stackoverflow has more information on this: http://en.wikipedia.org/wiki/Color_difference http://stackoverflow.com/questions/9018016/how-to-compare-two-colors cheers, Torsten __

Re: Color closest to color

2014-06-17 Thread Scott Ribe
On Jun 17, 2014, at 7:14 AM, Mills, Steve wrote: > The algorithm I've seen then takes the square root of that value. If the square root of a is larger than the square root of b, then a is larger than b ;-) (In this case a & b will both be positive.) -- Scott Ribe scott_r...@elevated-dev.com

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
Square rooting is slow, and not calculating square root do not throw off comparison. On Jun 17, 2014, at 21:14, Mills, Steve wrote: > On Jun 17, 2014, at 06:43:54, Maxthon Chan wrote: > >> One easy-to-implement method: colour cube. >> >> Define a colour using its RGB values as a 3-tuple (r,

Re: Color closest to color

2014-06-17 Thread Mills, Steve
On Jun 17, 2014, at 06:43:54, Maxthon Chan wrote: > One easy-to-implement method: colour cube. > > Define a colour using its RGB values as a 3-tuple (r, g, b) and standard > colours (ri, gi, bi) (where i = 0..n).The square distance between the given > colour and a standard colour is (ri-r)^2+(

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
One easy-to-implement method: colour cube. Define a colour using its RGB values as a 3-tuple (r, g, b) and standard colours (ri, gi, bi) (where i = 0..n).The square distance between the given colour and a standard colour is (ri-r)^2+(gi-g)^2+(bi-b)^2. You can calculate square distances between

Color closest to color

2014-06-17 Thread Jonathan Taylor
Hi all, Is there a way of identifying the closest match to a given NSColor, out of a list of possible colors to match? The user could have selected any color using the color picker, but I would like to know whether it is "approximately red", green, blue or white. Of course, it might be e.g. ma