How to calculate other colors with the same perceived lightness as a given gray value?
This is related to a question I asked on tex.stackexchange, which has a color aspect. The result of that question is the following image:
I have drawn a series of gray squares on the left, with a red branch departing to the right. The goal is to have different red squares with a different saturation, but all with the same gray value. In the hsv color model, they all have the same
v, but when I convert the image to grayscale using Gimp, they are not converted to the same gray. Also the visual impression is that the red squares on the right are darker than those on the left.
How can I, given a certain gray, calculate colors with a certain hue and the same gray value (or, even better, with the same gray impression)? The colors used in the image are all calculated, so I prefer solutions that incorporate calculations as well.
I might have used wrong terms here - I'm a mechanical engineer, so please correct me where appropriate, or ask for clarification.
The suggestion to use the Lab color space has led me to some conclusions:
I can use the Lab model's
Lvalue to set some kind of gray value for different colors. In the hsv model this is
v. I'm not sure if I am actually allowed to compare those, but I'll do it until someone complains.
In the hsv model I can also set some "base color" (a hue), which I can't find in the Lab model.
In the hsv model, I have 2 constants (in the image above:
v= 0.375) and one variable (
Up to this point, I only have one constant in the Lab model. That is not enough to generate something similar to what I already made with the hsv model.
I guess it's time for experiments.
Done! After I got the conversion code running, it was wuite easy. The first step was to define the "target red" on the right. I calculated RGB2Lab(255,0,0) and changed the L value of the result to the desired L in the figure (L = 62.5). The colors are calculated using a linear interpolation in Lab space from (L,0,0) to (L,aTarget,bTarget). The result:
You could use Lab colour space to find your matches. Colours with the same L value as your target gray will look nearly identical when converted to grayscale.
For example, a Lab gray of (50, 0, 0), will look very similar to the Lab reds (50, 30, 0), (50, 50, 30), and (50, 50, 50) when converted to grayscale. Samples below use Photoshop (Image > Mode > Grayscale) to convert from Lab to gray: