Linear vs. Gamma
Many users know the name ‘sRGB’ and ‘aRGB’ as the color space applied on the photo. When consider a channel of 8 bits in sRGB (or aRGB ), which varied from 0-255, few users knows the answer of this question, which value represents the half energy of the white point (255)?
You may say 127 because it is half value of 255, but the true answer is around 190, (the exactly value depends on the color space). Strange, isn’t it?
That is because the 8bits, 0-255 value, is calculated on a gamma-space, which is not linear. That means the value 255 is not represent double bright than the value 128, and the value 32 is not 1/4 bright of the value 127…
The gamma curve theory is based on responding of the human-eye. The following figure shows the different between linear and gamma space.
You may have more questions, but in this article, it is not important why or how, but what effect it will brings to the image in their processing results.
Considering an operation that blending 2 pixels together, one is white (255), one is black (0). The result in gamma space is 127 as the middle value of the two inputs. In linear space, we get 1.0 and 0.0 for the inputs as float value. So the result is 0.5. After transform from linear space to gamma space, we get 189 in sRGB space. The following figure shows two results.
As the above figure, when blurring the pattern, which constructed by white and black pixels, the linear space result is more accurate to the real feeling of human eye. If you look at the figure from a distance, with a calibrated monitor, you can see the fact clearly. Feel familiar with this? Yes, this is the standard way to calibrate the monitor’s gamma value. So you can understand, to running a operation like ‘blur’ in gamma space will brings a ‘wrong’ result. If you test other software by using this pattern, you can find a most of them are running under gamma space,.
So, any processing including a ‘blending’ operation inside may lead to a wrong result if the gamma space value is used. Let’s think about another example, the RGB to grayscale processing. The simple formula is:
L = R * 0.3 + G*0.6 + B * 0.1
Where L is the grayscale outputting, R,G, B are the Red, the Green and the Blue channel values.
In theory, these R, G, B value represents the real energy power that means it should calculated in linear space. But, most software does it in gamma space and gets wrong outputting as following sample. This is a repeatable and simple experiment that testing any image software and you can do it yourself. And then, you will find most popular software can not output the good result of grayscale like linear space do. As a professional photographer, this is a serious problem.
In conclusion, you can benefit from linear space for its accuracy in processing where blending is involved. Gamma space still has its advantage too. It brings better result and easy to understand on traditional functions like ‘curve’, ‘auto level’, etc. To archive the best balance, in the Light Developer, gamma space is simulated or optional when running those functions; except them, linear space is used in the algorithms in default.
Refer to 'Tone maker'.
Editing in 16bits per channel
Most digital camera support RAW format and many photographers have selected RAW as their preference. Compare to a JPEG file, RAW format can keep the original data from the camera sensor, which output 12bits per channel normally.
For 8 bits format like JPEG, it contains 256 scales of changing. For a long time, photo editing software works in 8-bits gamma space like JPEG system do. 8 bits is enough for most of the processing.
With the RAW format get popular, 8 bits is not enough to keep all information of the 12 bits inputs. So the software must be upgraded to 16 bits (2 bytes) channel to adapt it. The advantage of 16bits per channel is obvious: It keeps all details and provides more flexibility to editing the photo.
Based on the above reasons, Light Developer chooses 16 bits per channel, which is in linear space, as its internal image formats.