A question about colour spaces, thrown in amongst this:

How does colour space affect the linear rgb transforms? My knowledge of colour spaces is rusty, so I could be way off the mark here... is it a case that a linear rgb transform in one colour space wouldn't equal a linear transform in another space if the original and the transformed where shifted to that other space? So, if I had an image in prophoto and did a linear rgb scale on it like you've done, Guillermo, and then transformed both the original image and the scaled image to sRGB, would they show a linear relationship in sRGB? i.e. would the r:g:b ratios be the same?

As long as the profile conversion is performed using a linear matrix (like DCRAW does) there is no change in the result:

Rout = Rin * a11 + Gin * a12 + Bin * a13

Gout = Rin * a21 + Gin * a22 + Bin * a23

Bout = Rin * a31 + Gin * a32 + Bin * a33

If we now scale (Rout, Gout, Bout) by K we get (Rout', Gout', Bout') = (K * Rout, K * Gout, K * Bout)

What if we had scaled (Rin, Gin, Bin) by K prior to the conversion? (K * Rin, K * Gin, K * Bin)

Rout' = (K * Rin) * a11 + (K * Gin) * a12 + (K * Bin) * a13 = K * (Rin * a11 + Gin * a12 + Bin * a13) = K * Rout

Gout' = (K * Rin) * a21 + (K * Gin) * a22 + (K * Bin) * a23 = K * (Rin * a21 + Gin * a22 + Bin * a23) = K * Gout

Bout' = (K * Rin) * a31 + (K * Gin) * a32 + (K * Bin) * a33 = K * (Rin * a31 + Gin * a32 + Bin * a33) = K * Bout

The problem is that colour conversions in commercial software are not likely to behave this way; I recall conversations in the forum confirming ACR profile conversions are not so straightforward. They are more complex, surely for a good reason, but losing linearity.

Then you have the added difficulty that some popular colour spaces (e.g. sRGB) don't have a pure gamma. The sRGB gamma curve again breaks the ideal linearity while Adobe RGB and ProPhoto RGB pure gammas don't.

Regards