Layer Mode: Addition equation is working differently to official guide - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions) +--- Thread: Layer Mode: Addition equation is working differently to official guide (/Thread-Layer-Mode-Addition-equation-is-working-differently-to-official-guide) |
Layer Mode: Addition equation is working differently to official guide - wonder13662 - 03-07-2024 Hi, I'm a newbie and using GIMP(2.10.36) on Mac for several months. I have a question about Layer Mode: Addition. According to the official guide, the Addition equation is "The pixel values of the upper and lower layers are added to each other. The resulting image is usually lighter." So I made my own example to make sure this equation. 1. Top Layer(RGB Red): 227.0 2. Bottom Layer(RGB Red): 53.0 3. Resulting Image(RGB Red): 232.0 As far as I know, the Addition equation would be "E = min((M + I), 255)". According to the equation, "E = min((227.0 + 53.0), 255)" should yield 255. However, I got 232.0 as a result. Why does it happen? RE: Layer Mode: Addition equation is working differently to official guide - Ofnuts - 03-07-2024 No, because Gimp 2.10 is working in "Linear light". The 0 .. 255 values are gamma-corrected. In other words,they don't represent directly the amount of light in the color channel, but some encoding which is convenient to pack as much as possible of the visual range in 255 values, taking in consideration that our eyes are more sensitives to differences in low values. If you image is in some high precision linear mode, you can check the linear value with the Pixel representation in the Pointer and Sample points dialog In theory this would mean: Linear = ( RGB255 / 255 ) ^ 2.2 and RGB255 = 255 * ( Linear ^ ( 1 / 2.2 ) ) In practice the conversion is done using the image color profile but if the color profile is sRGB (which is the case most of the time), the formulas above give a good approximation. For instance your top color: [attachment=11403]
So Addition mode is really "Convert to Linear, add the values, convert back to RGB255", and using the formulas you are not so far off:
[attachment=11406]
[attachment=11407]
Note that you can ask Gimp to work directly with the RGB255 values, by using the "Legacy" layer modes: [attachment=11410]
In which case the result is probably what you expect: [attachment=11411]
However, if this makes mathematical sense, this has no relation to the physical reality. RE: Layer Mode: Addition equation is working differently to official guide - wonder13662 - 03-07-2024 (03-07-2024, 08:50 AM)Ofnuts Wrote: No, because Gimp 2.10 is working in "Linear light". Thanks a lot, Ofnuts. Now I realize why the official guide says "pixel value". May I ask another question? I'd like to learn more about the concept of "Linear light". Would you recommend any reference or documentation? I did several Google searches but I didn't get any good answer. Thanks in advance! RE: Layer Mode: Addition equation is working differently to official guide - Ofnuts - 03-07-2024 It's not "linear light" which is a concept, it is "gamma correction". Linear light is just the ratio of the channel value to the maximum possible value (perfect diffused reflection) and is really what you see. Quick experiment:
[attachment=11415]
[attachment=11417]
If you try the same thing on Gimp 2.8 (that works directly on the gamma-corrected value) that same filter yields a #7F7F7F and the pixellized areas are much darker:[attachment=11416]
(*) Because scaling directly on the gamma values (as done by many apps when doing thumbnails/previews) introduces the same kind of erroneous behavior as Gimp 2.8 Pixellize RE: Layer Mode: Addition equation is working differently to official guide - Ofnuts - 07-16-2024 Eventually wrote a tutorial on this, see https://www.gimp-forum.net/Thread-What-is-the-gamma-encoding-and-why-are-my-color-computations-wrong |