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 <[email protected]> wrote:
> 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 protected]> 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 protected]> >> 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 protected]) >>> >>> 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: >>> https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com >>> >>> This email sent to [email protected] >> >
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
