It is currently Sun Jul 21, 2024 6:21 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 12:47 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
I'll start with a foreword before I get to the point.
Overlay mode in GIMP is a well known 'legacy' bug, fixing it was just a matter of easy patching but the developing team left it as it is.
As a sign of respect to Spencer Kimball and Peter Mattis.
It is going to be fixed, though, as soon as GIMP goes all-GEGL.
But right now Overlay mode is actually the Soft Light mode.

To make a comparison chart I used these two images as layers


target layer ============== modify layer


ImageImage


Below is a standard of what Overlay mode should look like (I've done it with Krita, PS and TwistedBrush Pro,
they all look the same, so I'm posting here just one done with Krita).


Image



Below is a chart for discussions.
GEGL layer blending was done with GIMP 2.8.0 ( where Use GEGL was still available)
GIMP blending - with the latest stable version, 2.8.2 (GEGL function unavailable, only some GEGL operations)
PS - with PS CS6
G'MIC - with 1.5.3.0 version on GIMP 2.8.2.

Image

'Multiply' blending mode looks identical for all programs. (I've chosen to display Multiply mode, because Overlay mode is a combination of Multiply and Screen modes)
Overlay blending by GEGL and PS look close but not identical (to compare, we can place one atop of the other, set blend mode to Difference and look at the histogram. Ideal match is a completely black image with flat histogram)
GIMP Overlay blend mode, as expected, is identical to Soft Light of almost any other image editing program.
A big mystery are the Overlay and Soft Light blending modes in G'MIC.
What is wrong with it?

I need someone to explain me blend modes in GMIC.
Hope, David reads this, as the main GMIC architect, he always has a good answer.

Thank you.


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: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 1:39 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Interesting, did you try to swap the layers to see if there's a difference ?
Looks like a bug otherwise and I have probably to fix it.


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 3:36 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
Thank you for the quick response, David.

When I change the order of layers it gives the correct blending.
But this is a bit confusing and counter-intuitive because I need to move the top layer (gradient fill),
which I used as Modify layer in all other examples, to the bottom.

Is it fixable?


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 9:31 am  (#4) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
If layers are swapped what you got from overlay should be identical to "hard light" (...till opacity is
100% )

Somehow the order of layers when applying merging mode in gmic always baffled me,i always had to try both ways (to swap layers) to find the right one

as far for multiply i suppose you found correct because for its math result is the same whatever is the layer position but only till opacity is at 100% ! ...lowering that the layers position become relevant.

To check if are difference you should check also at other level of transparency (i.e. 75 ) that will show also if the position of the layer is that supposed

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 11:18 am  (#5) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Well it seems that when you set input to "All" in gmic plugin the top i.e. highest up on the layer list in gimp becomes the first or bottom layer in gmic's image stack (image [0] in gmic language). This confused me recently since I made a filter to merge layers and I had to reverse things unexpectedly. It didn't seem quite right to me but perhaps there is a reason for it, I'm sure David will explain :)

If it's changed now it could potentially mess up how some of the existing gmic filters work so they might need re-written (which can be a problem if the authors are long gone).


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 11:33 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
Thanks, PC!
Multiply and Screen modes are correct in GMIC without swapping layers. Overlay mode is just a derivative of these too,
but the base and modify layers have to swapped? That's what confuses me.
Lowering the opacity didn't work for Overlay, I tried that after seeing Overlay math formula last night.

garagecoder wrote:
Well it seems that when you set input to "All" in g'mic plugin the top i.e. highest up on the layer list in gimp becomes the first or bottom layer in gmic's image stack (image [0] in gmic language). This confused me recently since I made a filter to merge layers and I had to reverse things unexpectedly. It didn't seem quite right to me but perhaps there is a reason for it, I'm sure David will explain :)



Thank you! The right input mode should be Active and Below, then?


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 11:41 am  (#7) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Yes Active and Below should work as expected for two layers at a time. Now I'm thinking I might have to change my last filter since I was basing it on "All"!


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 12:07 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
OK, I had to make a run with Active&below input (although, I tried it last night too).
Multiply mode is correct.
Screen mode is correct but only with opacity set to 0.5.
Overlay=Multiply+0.5 Screen, but GMIC obviously sets Screen to 1.0 when applies the math
and that results in incorrect blending. Lowering the opacity in Overlay results in absolutely incorrect blending,
still have to swap the layers.
Soft light should be just 0.75-0.5 of the Overlay mode.
I ran through other blend modes as well.
In some cases layers have to be swapped, in some cases - not.
Some blend modes in GMIC are unique (like xor or freeze), no way for me to find out the right order of layers in a stack of layers.


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 12:50 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
K1TesseraEna wrote:
OK, I had to make a run with Active&below input (although, I tried it last night too).
Multiply mode is correct.
Screen mode is correct but only with opacity set to 0.5.
Overlay=Multiply+0.5 Screen, but GMIC obviously sets Screen to 1.0 when applies the math
and that results in incorrect blending. Lowering the opacity in Overlay results in absolutely incorrect blending,
still have to swap the layers.
Soft light should be just 0.75-0.5 of the Overlay mode.
I ran through other blend modes as well.
In some cases layers have to be swapped, in some cases - not.
Some blend modes in GMIC are unique (like xor or freeze), no way for me to find out the right order of layers in a stack of layers.


I'm not surprised that Multiply mode is layer position insensitive as multiplication is a mathematically commutative operation, the same as addition and in GIMP land so is Difference, Darken Only and Lighten only.

Overlay mode is curious, the unfixable mistake not withstanding, as Wikipedia has a different pair of equations: http://en.wikipedia.org/wiki/Blend_modes#Overlay so at this point the questions have to go out to David:- "Which order are the G'MIC layers used and which equations are being used for the various modes?"

Then the real cliff-hanger is when 2.10 comes along, what will GIMP do about supporting old files? Will it implement the old layer modes in the background but not allow you to use them going forwards? Or will there be the choice to use the old, incorrect, overlay mode?

Kevin


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 1:10 pm  (#10) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Payniky also for commutative mode result is identical only with 1 opacity setting ,100% , lowering opacity the position become relevant

Quote:
Overlay=Multiply+0.5 Screen, but GMIC obviously sets Screen to 1.0 when applies the math
and that results in incorrect blending. Lowering the opacity in Overlay results in absolutely incorrect blending,
still have to swap the layers.
Soft light should be just 0.75-0.5 of the Overlay mode.


not sure here , from where you derived something as Overlay=Multiply+0.5 Screen, and Soft light should be just 0.75-0.5 of the Overlay mode ?

The second in particular doesn't seems me correct, and here the situation is a bit confusing because exist more then 1 formula for Overlay

Anyway i had several time the sensation that to get the correct result i had to apply modes in the "wrong order" i mean on swapped layers or use trick as use "Hard light" to replace "Overlay" or "Soft light" because using soft light when lowering opacity apparently was the "wrong layer" to fade.
(but fading as if was on top in the right mode but was the wrong layer of the 2, i hope the sense is clear )

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 1:41 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
PhotoComix wrote:
not sure here , from where you derived something as Overlay=Multiply+0.5 Screen, and Soft light should be just 0.75-0.5 of the Overlay mode ?

The second in particular doesn't seems me correct, and here the situation is a bit confusing because exist more then 1 formula for Overlay



It may not be correct mathematically, I just go with current GMIC calculations and experimenting a bit.
We can't really argue here before we know exactly what formula is used for Overlay mode in GMIC, like Kevin said, only David can answer this.


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 3:36 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Hi,
I've made these blending filters a long time ago, so I'm not sure how I choose the order of the layers.
What I can say is I used the formula from there, if I remember well :
http://www.simplefilter.de/en/basics/mixmods.html

and that in the G'MIC plug-in, the layers are ordered from the top layer (image [0]) to the bottom layer (a Garagecoder said). Maybe some of the G'MIC blending modes are not correctly ordered or does not use proper formulas. If this is the case, then yes, I need to fix that as soon as possible, even if that breaks some code using these incorrect (for now) blending modes. I'm not a fan of keeping bugs too much time, just for compatibility reasons.


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 4:13 pm  (#13) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
I've tested a few and here are the differences I noticed from gimp 2.8.0 :

burn - reversed
divide - reversed
grain extract - different calculation
hard light - reversed
overlay - reversed
softlight - reversed

A few of them behave strangely since it appears you are controlling the opacity of the wrong layer but I assume that's just due to the reversal.


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Sun Jan 20, 2013 10:52 pm  (#14) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
garagecoder wrote:
I've tested a few and here are the differences I noticed from gimp 2.8.0 :

burn - reversed
divide - reversed
grain extract - different calculation
hard light - reversed
overlay - reversed
softlight - reversed

A few of them behave strangely since it appears you are controlling the opacity of the wrong layer but I assume that's just due to the reversal.


i was never able to explain what what baffling me regarding layer modes and layer position , i believe here you explain well
Quote:
"A few of them behave strangely since it appears you are controlling the opacity of the wrong layer"
i will say some look correct at full opacity, then when is lowered seems that is the wrong layer to have opacity lowered but also simultaneously to be moved on "top"
(because if was lowered the opacity of the base layers effect would be , for not commutative mode very different , instead is how if is lowered opacity of the top layer but suddenly is the wrong layer to be on top )

What looks more complex is fix without break a lot of filters that may have create nice effects adapting "wrong" mode , i believe this old modes should be maintained at least temporary, and hopefully progressively replaced by the correct ones..
.maybe using same names but with a added prefix to help to distinguish the new correct version

Or if capital letters are supported that could be a way to distinguish ,as -Softlight(revised) and -soflight(that used now )

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Mon Jan 21, 2013 4:35 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Well, I've done some fixes to make the G'MIC blending modes more correct.
Now, the order of the layers should be logical when using the plug-in.

For G'MIC script writers (garagecoder) : Note that the '-compose_*' commands were assuming that the image [0] was the background (bottom layer), and [1] the foreground (top layer). It is always the case, I didn't change this order, to avoid breaking all compose functions. Some of these 'compose_*' commands were also incorrect as they were considering reverted layers (as compose_lightness, compose_hue, etc..), but most were OK.
The only thing I've made is to consider now that GIMP specific blending commands '-gimp_compose_*' assumes now that the layers are ordered in the GIMP order (so top layer is [0] and bottom layer is [1]). This is the reverse of the 'compose_*' command, but as they are GIMP-specific commands, I prefer that they follow the 'natural' order of layers brought by the plug-in.


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Mon Jan 21, 2013 6:14 am  (#16) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
OK so if I understand correctly the basic compose_ commands (those in the reference page) are unchanged but the gimp_ specific ones are? I think that makes sense, hopefully not too many filters affected ;)
So at least now the [blend] filters in the filter tree will work as most expect, that's the main thing!


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Mon Jan 21, 2013 7:03 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Yes exactly.
To be honest, I'm currently developing new 'blend_*' commands to replace the '-compose_' ones, with more blending modes than before, and having the possibility to choose the opacity as well.
So GIMP blending commands will use them (as well as old '-compose_*' which will become deprecated in the future).


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Mon Jan 21, 2013 11:18 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
You are da man, David! :tyspin


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Mon Jan 21, 2013 5:13 pm  (#19) 
Offline
GimpChat Member

Joined: Jan 21, 2013
Posts: 33
Hello everyone,

Ronounours wrote:
> To be honest, I'm currently developing new 'blend_*' command

Wow. Great to know indeed!

I have read krita supports the largest set of blending mode among open source softwares (correct me if I am wrong...).
More precisely, it looks like there are around 71 of them.
Unfortunately, right now, I can not paste here the link with their descriptions (my web-link is deemed "spammer"...).

Just to list some of them:
Arcus Tangent, Gamma Light, Gamma Dark, Geometric Mean, Vivid Light, Pin Light, Grain Merge", "Grain Extract", "Hard Mix", "Copy Red/Green/Blue/Opacy", Additive-Substractive, improved divide, Soft Light, Hard Light, Atop, HSY, HSV, HSL, HSI, dissolve and Overlay

Perhaps, some of them, might be added in some future versions of G'mic

Best regards

Silvio Grosso


Top
 Post subject: Re: GMIC "Overlay" and 'Soft Light" blend modes
PostPosted: Tue Jan 22, 2013 12:31 pm  (#20) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Some more words about my recent developments of G'MIC blending modes :

http://www.flickr.com/groups/gmic/discu ... 587736884/

It will rock :D, but due to a bug in command '-image', it will be only available for the next stable release (1.5.4.0), and I cannot backport these new commands to current stable versions.


Top
Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GEGL Color Light Fusion (12 blend modes for color overlay)

9

No new posts Attachment(s) Is there anyway to add blend modes inbetween operations in Bimp?

2

No new posts Attachment(s) How to reproduce Gimp's levels using blend modes of color fills

0

No new posts Attachment(s) GEGL Custom Bevel - Change internal blend modes, blur types & more

39

No new posts Pattern Overlay Errors

1



* Login  



Powered by phpBB3 © phpBB Group