A look at terminal emulators, part 1
A look at terminal emulators, part 1
Posted Apr 17, 2018 20:18 UTC (Tue) by Ross (guest, #4065)In reply to: A look at terminal emulators, part 1 by borisfaure
Parent article: A look at terminal emulators, part 1
But that's an interesting point about color distances.
XTerm doesn't just use Euclidian distance. It's kind of messy. See allocateClosestRGB() for allocations and searchColors() for finding matches.
xtermClosestColor() does work as you suggest when matching colors on a paletted display (or if not compiled with DirectColor support). find_color_register() for graphics uses weighted Euclidian distance, and it doesn't seem to take advantage of DirectColor (that's my fault).
I'd immediately replace all of these, but there are two problems with the CIEDE2000 formula:
* it most likely assumes linear response per channel -- this is usually not true with raw RGB
correcting for this is either a lookup table per channel (but it is hard to know which values to
plug in) or it isn't clear how to adapt the formula
* the formula would be very slow as they would require colorspace conversion in addition
to lots of multiplications, divisions, and square root operations in the computation itself
The last formula in the Euclidian section which you mention looks reasonable, but the first issue
probably still applies. How do you handle that? How much better is it than the weighted Euclidian
distance? It would be nice to have a way to measure match quality to test various approximations.