It is currently Thu Jun 27, 2024 7:22 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Wed Oct 19, 2022 9:00 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
GIMP Version: 2.8.14
Operating System: Linux
GIMP Experience: Experienced User



In another thread, I tried to understand different behaviors by asking about the operation(s) of Layer Groups.

Since then however I've discovered, I think, at least in the case of Subtract layer mode, a Legacy layer produces the expected output as described in the GIMP 2.10 documentation, and a Default layer does not. The documentation says the equation for a Subtract layer is supposed to be:
E=max((I-M),0)
where I is the underlying image layer and M is the upper mask. I don't think it is. Of course I might have some silly setting staring me in the face that I can't perceive.

Do correct me and I'll edit--or Delete--this post.
[EDIT: I had quite forgotten about this earlier post re: the Default/Legacy differences, it being a Whole Week ago.]

I also found this interesting, but dated 2018, interchange affecting some more ethereal differences btwn Default and Layer. In that discussion, Elle Stone--may the name be duly revered--mentions "right-clicking on a layer in the list, and clicking 'Perceptual' under 'Composite Space"; however, neither of the options changes the output.

Here's a simple comparison in which an 80% gray layer is subtracted from a white layer in Default and Legacy modes.
Image

(I've attached the project file too.)


Attachments:
Study_LegacyModeSubtract.xcf [235.19 KiB]
Downloaded 47 times
Study_LegacyModeSubtract.png
Study_LegacyModeSubtract.png [ 97.68 KiB | Viewed 1063 times ]

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Wed Oct 19, 2022 9:47 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
How do you define 80% gray?

Create two images, one 8-bit integer perceptual (the usual 2.8 kind), one 32-bit FP linear.

Paint them both with #bbbbbb which is the exact 50% gray (from a distance, you can't distinguish it from an image with a black and white checkerboard). Explore them with the Pointer dialog. The "pixel" display of the 8-bit one gives the expected (187,187,187), but the same display in the 32-bit one says (.50,.50,.50). This is because (187/255)^2.24=0.50 (2.24 is the "gamma").

What is displayed is always perceptual. But in the normal case, Gimp will work on linear values, so what you get is gamma[1-reverse_gamma(gray)], while in legacy it works on the gamma values directly (as it did in 2.8) you get [1-gray].

_________________
Image


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Wed Oct 19, 2022 11:16 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
First I confess all my images are 8-bit integer perceptual because that's the default=I am lazy. Having said that, I assumed that that was the explanation, and that the difference would disappear when I went to 32-bit floating point. Not so.
ofnuts wrote:
How do you define 80% gray?

On the foreground color pulldown, I put '80' in the 'L' field--whatever that means, for whatever 'L' means. Lightness?
ofnuts wrote:
Create two images, one 8-bit integer perceptual (the usual 2.8 kind), one 32-bit FP linear...

What is displayed is always perceptual. But in the normal case, Gimp will work on linear values, so what you get is gamma[1-reverse_gamma(gray)], while in legacy it works on the gamma values directly (as it did in 2.8) you get [1-gray].


I did, not quite, as you suggested: creating one new 32-bit Floating Point (FP) linear image and creating new layers rather than risking copying layers out of the old 8-bit image, which in fact it was.

To create the New image, I had to File->New, +Advanced Options, and click on 32-bit Floating Point (FP) for Precision and Linear Light for Gamma.

I created a WHITE layer and put a text 'A' letter, colored 'bbbbbb', on two different layers above it: a Default and a Legacy. In Subtract mode, the results are indeed different. I created a New Layer from Visible, and used the Pointer dialog to examine pixels in each. (I'm glad you mentioned 'dialog' because I had just been reading about 'Dialogs' vs. 'Windows' and knew to go to Windows->Dockable Dialogs to enable the Pointer which I've never had open.)

On the New Visible layer, resting the Pointer over a Legacy-mode Subtracted pixel, the color is reported as '444444' (White/'ffffff' - 50%/'bbbbbb'). Over a Default-mode subtraction, the color is 'bcbcbc.'

Seeing the obvious difference, I thought that it might be a result of the image having Linear gamma so I created another New image with 32-bit FP and Perceptual gamma.

The result was the same: Subtract operates differently on Default and Legacy layers.

The QUESTION:
Is there a way to get the Legacy-mode Subtract result using only-Default modes?

If not, I'll at least know why I'm attached to Legacy. :^)

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Wed Oct 19, 2022 4:21 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
As I said above; "#bbbbbb" is not 80% gray, it is 50% gray. This the proof:

Attachment:
50-gray.png
50-gray.png [ 2.58 KiB | Viewed 1021 times ]


With the image above on your screen, step back (or like me, remove your glasses) until you can't make out the pixels in the left part. You'll notice that both sides look the same(*), so #bdbdbd is the color of something that is the same as half black and half white. In "linear light", this is .5, in other words, one half. So in linear subtract mode, If you subtract half gray (.5) from white (1.0) you get .5 again, and this .5 value is gamma corrected for the display so shows up as #bdbdbd".

Which is correct... because if you subtract half-gray from white, you should get half-gray. In the image above, if I add a layer of white under the image, and put the test layer in subtract mode, in the left part, the white pixels subtracted from the white give 0 (black) and the black pixels subtracted from the white leave the white. So the subtraction just inverted the pattern which is still 50% gray, and still the same as #bdbdbd.

Attachment:
Subtract-Default.png
Subtract-Default.png [ 23.46 KiB | Viewed 1021 times ]


If you switch to Legacy mode, then Gimp works directly on Gamma values so you get 0xFF-0xBB=0x44:

Attachment:
Subtract-Legacy.png
Subtract-Legacy.png [ 23.29 KiB | Viewed 1021 times ]


Which is what you expect but is not coherent with what you have on the left.

So, legacy mode is the one where you can compute things easily, and the one you are used to, but it is not the one with correct results.

(*) to be fair, this depends a bit on the gamma rendering of your display. AFAIK Gimp assumes a gamma of 2.24. You can try to find the gray that most closely matches the luminosity of a checkerboard for your display(**), and it will still be in the 0xA8-0xC8 range and not around 0x80.

(**) Fill with #808080 and play brightness, then use the Pointer to check the resulting value.

_________________
Image


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Thu Oct 20, 2022 10:18 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
ofnuts wrote:
...
Attachment:
50-gray.png


With the image above on your screen, step back...


I could not understand what you meant until I thought to zoom in on the image, after which the non-uniform nature of the LH-side becomes apparent. The lighter pixels embedded in the dark background do in fact fade for me at 10-12 feet.

Further down, this quote explains for me my misunderstanding based on my assumptions:
ofnuts wrote:
So, legacy mode is the one where you can compute things easily, and the one you are used to, but it is not the one with correct results.

(*) to be fair, this depends a bit on the gamma rendering of your display. ...


I'm using GIMP to create heightmaps for CNC models. In the event, Default mode distorts the result assuming the goal is "correct" rendering on a monitor when in fact the intent is "correct" rendering for a 3D digital model.

Thank you for clarifying this for me.

I'm still under the impression that "Legacy" mode might disappear someday, so I would prefer to be able to achieve the same effect with Default mode(s).

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Thu Oct 20, 2022 12:33 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
gramp wrote:
I'm using GIMP to create heightmaps for CNC models.


So you are basically using Gimp to do math, which is not something it was designed for.

This said, did you try to work in 8-bit linear mode (and using default blend modes?)

_________________
Image


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Thu Oct 20, 2022 1:25 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
ofnuts wrote:
gramp wrote:
I'm using GIMP to create heightmaps for CNC models.


So you are basically using Gimp to do math, which is not something it was designed for.


Having worked in software support, I became convinced that while programmers may code a tool for particular uses, users will ultimately demonstrate all the other uses.

Having said that, I think GIMP is a powerful mathematical tool, and although I had to do a lot of experimenting, underlying it was a deep confidence that GIMP was completely up to the task. (G'Mic was a happy bonus, although I resort to it sparingly.)

ofnuts wrote:
This said, did you try to work in 8-bit linear mode (and using default blend modes?)


I never did actually, before moving "up" to 32-bit mode--which I only realize now did not bestow the ability to deal with 232 graylevels, up from 28, as I'd assumed.

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Fri Oct 21, 2022 7:07 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Oct 09, 2022
Posts: 22
Location: Hungary
"while programmers may code a tool for particular uses, users will ultimately demonstrate all the other uses"
Exactly!

_________________
Image
DeviantArt GIMP Gallery


Top
 Post subject: Re: Default vs. Legacy: "Subtract" Layer Mode: Different results
PostPosted: Fri Oct 21, 2022 10:07 am  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
True for many things. As the flight manager of Apollo 13 said to the engineers, "I don't want you to tell me what every device has been designed for, but what every device could be used for". This is also a state of mind of hackers and lockpickers.

But then, if the "designed for" device changes and your not-designed-for usage breaks, you can't complain.

_________________
Image


Top
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Change all layer modes from Legacy to Default

9

No new posts The difference between Layer modes Legacy and Default

1

No new posts Attachment(s) layer mode preview stopped working

3

No new posts PARTIALLY SOLVED How does it work on layer blendng mode "Normal"

1

No new posts Attachment(s) How does it works on Layer Blending Mode "Add" with Alpha Channel?

4



* Login  



Powered by phpBB3 © phpBB Group