Find nearest color match

Let’s say you have a color, and you want to find the closest match in defined color scheme set. The first problem is defining what closest means. It’s not a simple problem to solve.

There are a number of approaches to this, the simplest being to measure the euclidean distance between two colors in a 3D color space – for example RGB, HSL, HSV etc. Here’s and article that shows how to do that.

However, these mathematical approaches do not really adjust for color perception. Another color model  CIEL*a*b*, has used various algorithms over the years to create better matches to take account of perceived color differences.

CIEDE2000

This is the latest CIE algorithm (from  wikipedia) for comparing two colors for closeness. It’s a monster
cie color matching algorithm

 

I thought I may as well implement this in VBA , javaScript and google apps script to add to my color function libraries. Here’s the VBA version. Luckily I found (by Gaurav Sharma, Wencheng Wu,Edul N. Dalal) this paper to get me started. The GAS version is at Color Matching in GAS