go-colorful: DistanceRGB doesn't use linear RGB

DistanceRGB should use linear RGB, as otherwise the distance doesn’t really hold any meaning, because it’s measuring a non-linear space.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 39

Most upvoted comments

I ask this because one of your earlier comments up here suggested that sRGB distance was better for human perception, but these images appear to contradict that.

This comment was made in reference to your OP.

The problem in the dithering case is different though. You can factor out the observer because what you are interested in here is basically energy conservation . The idea being that for a given pool of radiant power emitters, if you remove a certain numbers of them, by how much the radiant power of the remaining ones must be increased to be the same than that of the full pool. It is really a ratio and doing those operations in a linear space is totally appropriate!

Did it occurred to you that your preference WRT matching could be a display calibration issue?

Here is a gamma test: Generate a series of x10 96x96 checkerboard of decreasing luminance, each of them have the light colour halved from the previous one. Center those checkerboards against a 192x192 constant background with half the luminance of their respective checkerboard.

Encode that image with sRGB EOTF-1, then display it at 100%, if your display gamma is correct you should not see the checkerboards when slightly squinting, alternatively, test a Gamma 2.2 encoding. If none works, then your display is off chart!

The takeaway is that 1) it is important to make sure that your display is calibrated, 2) as you remove values, you remove the total energy arriving to your eyes so you need to increase luminance of dithered pixels to make things appear similar.

My understanding is that measuring euclidean distance in a non-linear space serves no purpose

This is correct!

and so when you measure euclidean distance in sRGB you aren’t measuring anything meaningful.

This is not correct, the reason being that while non-linearly encoded sRGB is non-linear from a photometric standpoint, it is actually more linear from a human observer standpoint, i.e. from a perceptual standpoint. If you were to compare the sRGB inverse EOTF and CIE L* used by CIE L*a*b*, you would see that while not being the same, they are closer together than a purely linear function.

image

Everything is a matter of reference point. With that in mind, I’m not saying that you should perform colour differences in non-linearly encoded sRGB space but if your goal is to generate perceptually smoother gradients and such things, it is better than linear sRGB.