Color similarity/distance in RGBA color space

Finally, I’ve found it! After thorough testing and experimentation my conclusions are: The correct way is to calculate maximum possible difference between the two colors. Formulas with any kind of estimated average/typical difference had room for discontinuities. I was unable to find a working formula that calculates the distance without blending RGBA colors with some … Read more

What exactly is BGR color space?

Its about endianness. RGB is a byte-order. But a deliberate implementation choice of most vanilla Graphics libraries is that they treat colours as unsigned 32-bit integers internally, with the three (or four, as alpha is typically included) components packed into the integer. On a little-endian machine (such as x86) the integer 0x01020304 will actually be … Read more

Convert an image RGB->Lab with python

Since 2010 when the linked question was asked the corresponding code moved from scipy to a separate toolkit: http://scikit-image.org/ So here’s the code I was actually looking for: from skimage import io, color rgb = io.imread(filename) lab = color.rgb2lab(rgb) It should also be noted that due to Lab nature srgb->lab conversion depends on an additional … Read more

Is there an algorithm for color mixing that works like mixing real colors?

The correct answer is NO, because there is no correct working model of how “color mixing in the real world” really works. It is FAR too complex and conditional and not really at all like the simple Red-Blue-Yellow stuff that we learned in school (it in fact requires all of Chemistry and a lot of … Read more

What are the practical differences when working with colors in a linear vs. a non-linear RGB space?

Let’s say you’re working with RGB colors: each color is represented with three intensities or brightnesses. You’ve got to choose between “linear RGB” and “sRGB”. For now, we’ll simplify things by ignoring the three different intensities, and assume you just have one intensity: that is, you’re only dealing with shades of gray. In a linear … Read more

tech