atextor / icat

icat (Image cat) outputs images in 256-color capable terminals.
152 stars 12 forks source link

Sub-optimal color approximation due to Euclidean metric in RGB #9

Open jaseg opened 8 years ago

jaseg commented 8 years ago

Hi,

The Euclidean metric ( sqrt(a^2+b^2+c^2) ) does not approximate perceived color distance very well. In my version of this project (this seems to be one of these weird wheels everybody keeps reinventing^^) I used the LUV color space, where the Euclidean metric gives somewhat better (though still imperfect) results.

Also, using the ANSI standard palette (colors 0-16) is unwise for image display since users tend to re-define these colors using color themes in their terminal emulators.

Cheers, jaseg

atextor commented 8 years ago

Hi jaseg, both points are valid. Regarding colorspace, I honestly did give it not much thought. Now that we have an issue open, maybe someone wants to take it on and send a pull request. I know I probably won't for a while. You're right about redefined ANSI colors as well. The easy fix would be to just ignore those in the search. I also thought about reading the the corresponding X resources and use the acutally defined colors, but it's not that straightforward because it depends on the terminal emulator (i.e., you could have defined URxvt*color0 or XTerm*color0 and so on). Also I'm not sure the effort for the resulting minimal improvement is worth it.