somewhere to talk about random ideas and projects like everyone else



Perceptual color distance and RGB and L*a*b 31 May 2014


I was doing some experiments with clustering colors, and it turns out that RGB euclidean distance is woefully inadequate, so here’s a neat little visualization of the colors in an certain image (an obligatory cat) in Lab space (specifically the axes represent L and a).

So it turns out that comparing the difference between RGB colors is actually a really shitty way to determine color distance. There are colors which have similar RGB representations while being perceptually distant, and perceptually similar colors with vastly different representations.

So I decided to run a series of large scale double-blind (heh) experiments on human perception, analyzing the output with a dizzying array of statistical techniques and— oh wait, no I didn’t, because scientists have gotten that all figured out since the late ‘70s.

That group of color scientists, the International Commission on Illumination (CIE, acronyms are a bit weird when they’re international, and by international, I mean French), have been working tirelessly since the early 20th century to create increasingly nuanced mathematical models of color perception.

Rather than give up and use tables (of a slightly different sort), they’ve elected to add increasingly nuanced corrections to the originally elegant euclidean distance metric. Somewhere on that trek, they’ve actually abandoned the notion of actually being a metric- the DeltaE function, which defines how to calculate the perceptual distance between any two colors, is actually only a quasimetric— that is, it isn’t guaranteed that the distance from a point A to a point B is the same as the distance from point B to point A.

I originally wrote this blog post to be parody of all the buzz over the discover of evidence for Alan Guth’s cosmic inflationary theory (hence the diagram), but I kind of waited a while for the content to ferment (albeit not the decades requisite to be worthy of a Nobel).

So here’s a little library for converting between L*a*b* and sRGB, as well as computing DeltaE. There’s probably stuff like configuring the white point that I haven’t adequately considered, but this was good enough for my purposes of filtering colors for Project Naptha.

New Default Colors? 24 September 2009

Since the project started almost 3 years ago, the color scheme had been Red fill, Black stroke, and a stroke width of 1px. Is it time to change?

One idea is White for the fill, Black for stroke (same), and a 5px line instead. This makes lines more easily manipulated, but it tends to make rectangles large (and the canvas is small). The normal Black/Red/1px is the same used by Flash (as far as I know), and numerous other editing tools (including svg-edit).

So what do you think?

Color Tweening 22 July 2008

Well, I added josep_ssv’s color tweening system. I modified it a bit, but it should work fine.

Today's Updates II 26 May 2008

As I mentioned earlier, more would happen today. I’ve just made an update. I updated the Update system to also compile (it doesn’t compress anything yet, it really doesn’t need to) CSS files. This should speed up the application a bit, and should also make it easier when updating some smaller things. As with that, it will also starting from build 83, create release archives of the CSS files. The compiler mechanism has changed a bit too, but that’s not really important.

The most visible additions, is the embedded Color Dialog. If you look at the title, you’ll find a Steve Jobs reference. Right below the huge drawing tools list (what? is it like 2 times that of the old version?) there is a Line Width slider (this is indirectly inspired by OnlyPath’s Mondrian-style color picker). it also embeds the Color Field plugin, so if you press the little button on the side, a little color palette shows up. Ideally, this will enhance user’s efficiency and be less confusing than the old one.

I don’t know if I can make a “Today’s Updates III” :P

[EDIT] BTW, the page is located at