It is currently Sat Jul 06, 2024 4:53 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [SOLVED] "Grayscale arithmetic" (combining layers)
PostPosted: Fri Oct 19, 2018 12:30 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Hi, everyone. I haven't visited for a long time. I've been working. (at my age!)

Some of you may recall my abiding interest in (ab?)using Gimp to make grayscale heightmaps for CNC carvings. (PegLeg44 is another, and predates me.)

I upgraded to 2.10 as a result of a new Ubuntu install (I think's how it might've happened), and have been happy to discover my "images" can now contain 65535 grayscale levels (if I set Image->Resolution to 16-bit integer, and if I understand correctly).

I'm puzzling over the "arithmetic" involved in multiplying and adding layers. In short, I'd like to combine layers of equal maximum peak brightness (100%) by creating new layers for each by multiplying by a 50%-gray layer and then adding the two. In my mind, the two new layers should have resulting max brightnesses of 50% each and their sum then should have max brightness of 100% wherever the two's maxes overlap.

The results have not been as I expected, so I did a small test (attached) which resulted in a maximum brightness of only 67% instead of 100%.

Can someone remove my confusion and suggest a way to get what I'm after?

[Incidentally, I also chose "Linear Light", instead of "Perceptual Gamma", under Image->Precision, and verified that enabling/disabling "->Color Management" in the same location made no difference.]
Thank you.
gramp


Attachments:
grayscale_arithmetic_fail.png
grayscale_arithmetic_fail.png [ 22.47 KiB | Viewed 4907 times ]

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


Last edited by gramp on Sun Oct 21, 2018 7:00 am, edited 1 time in total.
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: Question on "grayscale arithmetic" (combining layers)
PostPosted: Fri Oct 19, 2018 1:17 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Referring to the Gimp docs, I can confirm:
* the maths for "Multiplication" of a Mask layer sitting above an Image layers is given as:
E=(M*I)/255
* the maths for "Addition" of a Mask layer sitting above an Image layer is given as:
E=min(M+I,255)

In my example, I=100%(255?), M=50%*I, everywhere.

The result of the lower multiplication is a new layer where:
E=(50%*255*255)/255=50%*255, everywhere.

The result of the upper addition should be then:
E=min(50%*255+50%*255,255)=100%*255

but it is 67%.

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


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Fri Oct 19, 2018 4:34 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Works as you expect if you use the "Legacy" mode on addition.

I suspect the new ("default") modes don't bluntly use the linear values, but do a gamma-conversion; otherwise, most blend modes wouldn't give the same result in "linear light" (which is itself more about storage than about processing).

_________________
Image


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Fri Oct 19, 2018 5:43 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Indeed, Ofnuts, just as you said: toggling between Addition and Addition(l) by choosing "Legacy" (instead of "Default") on the rightmost arrow pulldown (which offers to "Switch to another set of modes" when hovered over) instantly provides the result I expected!

(Now I'm curious if choosing legacy drops me back to 256 gray levels. Trying to figure out a way to test that.)

Thank you.
Gr.

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


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Sat Oct 20, 2018 7:32 am  (#5) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2439
Quote:
..(Now I'm curious if choosing legacy drops me back to 256 gray levels. Trying to figure out a way to test that.


Noticed some time before, but Colors -> Info -> Colorcube Analysis only works for 8 bit images.

For other than 8 bit images use Imagemagick

identify -format "%k" more-than-8-bit.tiff


Surprisingly little difference between 16 bit desaturated and greyscale, and legacy/default.

Of course in 8 bit where greyscale is 256 (or less)

sceenshot comparison: https://i.imgur.com/S78QX8n.jpg

_________________
Image


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Sat Oct 20, 2018 8:31 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
@Rich2005, never knew that either.

Your ImageMagick (I'm always confounded by why there's no binary named that...) 'identify' function says my output files are only 241 graylevels. As each level becomes a cutting-depth in a heightmap (or depthmap), the only benefit for more levels is for objects that are otherwise "too tall" and showing the "steps" between carved levels.

At least I'm back to 2.8 functionality, but perhaps there's a description of the new Default modes' formulas which will allow me to try to figure out parameter settings to get a similar result with them.

Thanks!
gramp

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


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Sat Oct 20, 2018 1:05 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Indeed, there is no mention of "legacy" or "default" modes (other than "Normal is the default when creating a new layer") on the Gimp 2.10 documentation on Layers (Section 2):
https://docs.gimp.org/2.10/en/gimp-conc ... modes.html

My guess is that a reasonable person reading the page will assume the equations presented apply to the "Default" mode, so my quest is unfinished.

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


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Sat Oct 20, 2018 1:25 pm  (#8) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2439
gramp wrote:
Indeed, there is no mention of "legacy" or "default" modes (other than "Normal is the default when creating a new layer") on the Gimp 2.10 documentation on Layers (Section 2):
https://docs.gimp.org/2.10/en/gimp-conc ... modes.html.


Other people have asked the same question ;)

https://discuss.pixls.us/t/gimp-2-10-la ... des/9416/4

_________________
Image


Top
 Post subject: Re: Question on "grayscale arithmetic" (combining layers)
PostPosted: Sat Oct 20, 2018 5:06 pm  (#9) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Okay, I Yamadope.

I spent a little time reading release notes[1] aimed at developers, but didn't stay long because at the first mention of "Tiff", I thought, "Hey! maybe That's it!" and rushed off to check.

But no, exporting as a .tif also produced an 8-bit file.

THAT however led me to check the Image->Precision mode setting--and BOOM! I found that I had NOT set it to a 16-bit output. (I had absent-mindedly SWITCHED projects AFTER setting the first one to 16-bit, and then opened the second without so much as a passing thought to its resolution--not being yet in the expectation of anything better than 8-bit.)

Well, I set it to 16-bit, exported a .PuNG file and it's a bona fide 16-bit!

[DELETED: request for "someone else" to edit the Subject of this post. Another oops.]

On closing, I emphasize Ofnuts' observation of the importance of using Legacy-mode layers.

[1] https://www.gimp.org/release-notes/gimp-2.10.html

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


Top
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Restoring faded grayscale document

6

No new posts Attachment(s) 16-bit grayscale graylevels "65535 available tonal steps": where?

5

No new posts Layers

2

No new posts Help with masks and layers please!

3

No new posts Attachment(s) Wrap all layers

4



* Login  



Powered by phpBB3 © phpBB Group