Re: Color closest to color
Re: Color closest to color
- Subject: Re: Color closest to color
- From: Jonathan Taylor <email@hidden>
- Date: Tue, 17 Jun 2014 15:02:45 +0100
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 <email@hidden> 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+(gi-g)^2+(bi-b)^2. You can calculate square distances between the given colour and each of the standard colours, and the one with the minimal squared distance is the best match.
>
> Better methods may exist, consult a book on computer vision or fine arts maybe?
>
> On Jun 17, 2014, at 18:52, Jonathan Taylor <email@hidden> wrote:
>
>> 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. magenta, and not really map well onto one of those four, but I would still be interested in knowing the best guess. It struck me that there might be an API for that, but I couldn't immediately find one.
>>
>> I could probably come up with a way of doing this myself, but thought I'd see if there was anything out there already.
>>
>> Cheers
>> Jonny.
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden