Author Topic: How to reproduce the various 'Blend' modes of PS in PixInsight?  (Read 19920 times)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Elsewhere on this section of the Forum (http://pixinsight.com/forum/index.php?topic=2381.15), Rogelio explained what the equivalent PixMath expression would be to achieve a 'Screen Blend' as used in PhotoShop.

What I just wondered is, for the sake of 'compatibility', does anybody know of similar expressions for the various other blending modes used by PS? (I am not promoting or advocating their use, I am simply curious because some of them - typically for PS - have been named so obscurely that it is very difficult to imagine what is going on 'behind the screens')

Any takers?
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #1 on: 2010 October 01 06:43:58 »
Hmmm. I have not seen a description of the other, more obscure methods. Since The Gimp implements almost every one of them, I suppose that it should be better documented on their manual ;)
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Enzo De Bernardini

  • PTeam Member
  • PixInsight Addict
  • ***
  • Posts: 274
  • Resistance is futile.
    • Astronomí­a Sur
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #2 on: 2010 October 01 08:02:54 »
Some time ago I had researched the matter, and I found this link helpful:

http://dunnbypaul.net/blends/

Regards,

Enzo.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #3 on: 2010 October 01 08:35:43 »
Exercise: write optimized PixelMath expressions for all of those 'blending modes'. :)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mmirot

  • PixInsight Padawan
  • ****
  • Posts: 881
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #4 on: 2010 October 01 08:58:18 »
Actually it would be nice to add some preset expressions to pixel math.
My memory is getting old.

Max

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #5 on: 2010 October 01 10:14:51 »
Hey Enzo, that was a great link :) The PM expressions are almost ready :D
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Enzo De Bernardini

  • PTeam Member
  • PixInsight Addict
  • ***
  • Posts: 274
  • Resistance is futile.
    • Astronomí­a Sur
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #6 on: 2010 October 01 10:27:56 »
Exercise: write optimized PixelMath expressions for all of those 'blending modes'. :)

I like the idea  :)

Vivid Light don't work like the image example. Edited: used a formula from this resource, works fine.
Soft Light works, but slightly different (marked on red).

Darken
Min( IMG1, IMG2 )

Multiply
IMG1 * IMG2

Color Burn (non-commutative)
1 - ( 1 - IMG1 ) / IMG2

Linear Burn
IMG1 + IMG2 - 1

Lighten
Max( IMG1, IMG2 )

Screen
1 - ( 1 - IMG1 ) * ( 1 - IMG2 )

Color Dodge (non-commutative)
IMG1 / ( 1 - IMG2 )

Overlay (non-commutative)
iif( IMG1 > 0.5, 1 - ( ( 1 - 2 * ( IMG1 - 0.5 ) ) * ( 1 - IMG2 ) ), ( 2 * IMG1 ) * IMG2 )

Soft Light (?) (non-commutative)
iif( IMG2 > 0.5, 1 - ( 1 - IMG1 ) * ( 1 - ( IMG2 - 0.5 ) ), IMG1 * ( IMG2 + 0.5 ) )

Hard Light (non-commutative)
iif( IMG2 > 0.5, 1 - ( 1 - IMG1 ) * ( 1 - 2 * ( IMG2 - 0.5 ) ), IMG1 * ( 2 * IMG2 ) )

Hard Mix
iif( IMG1 < 1 - IMG2, 0, 1 )

Vivid Light (non-commutative)
iif( IMG2 <= 0.5, 1 - ( 1 - IMG1 ) / ( 2 * ( IMG2 ) ), IMG1 / ( 2 * ( 1 - IMG2 ) ) )

Linear Light (non-commutative)
iif( IMG2 > 0.5, IMG1 + 2 * ( IMG2 - 0.5 ), IMG1 + 2 * IMG2 - 1 )

Pin Light (non-commutative)
iif( IMG2 > 0.5, Max( IMG1, 2 * ( IMG2 - 0.5 ) ), Min( IMG1, 2 * IMG2 ) )

Difference
Abs( IMG1 - IMG2 )

or else (thanks to Carlos Milovic)

IMG1 -- IMG2

Exclusion
0.5 - 2 * ( IMG1 - 0.5 ) * ( IMG2 - 0.5 )
« Last Edit: 2010 October 01 12:21:49 by Enzo De Bernardini »

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #7 on: 2010 October 01 10:49:29 »
For Difference, you may use the "--" operator.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Emanuele

  • PixInsight Addict
  • ***
  • Posts: 270
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #8 on: 2010 October 01 10:56:29 »
Just my humble opinion, but it would be realy awesome if pixel math would be simpler to use, instead of having to write those expressions every time, and remember them  ;D

Offline Enzo De Bernardini

  • PTeam Member
  • PixInsight Addict
  • ***
  • Posts: 274
  • Resistance is futile.
    • Astronomí­a Sur
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #9 on: 2010 October 01 10:58:47 »
For Difference, you may use the "--" operator.

Efficient :) I added this to the list.

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #10 on: 2010 October 01 11:01:41 »
Hi Emanuele
If you open the equation editor, there are lists of the functions and the operators... This helps a lot to build the expressions.


BTW, perhaps Juan should include a simplified PixelMath, like the one we had on the LE release... what do you think?
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Emanuele

  • PixInsight Addict
  • ***
  • Posts: 270
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #11 on: 2010 October 01 11:14:48 »
Thanks Carlos: Yes, I have seen the operator expression in PixelMath, but it's the logic between images that is a bit hard to come up with.

Simplified PixelMath sounds sweeeeeeeeeeeet!

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #12 on: 2010 October 01 12:10:55 »
Well done Enzo. 1 -x is the inverse of x. PixelMath provides the pixel inversion operator ~, namely:

~x = 1 - x

Knowing this you can simplify many of the expressions, and hence make them run faster. The whole set would be:

Darken
Min( IMG1, IMG2 )

Multiply
IMG1 * IMG2

Color Burn (non-commutative)
~(~IMG1/ IMG2)

Linear Burn
IMG1 + IMG2 - 1

Lighten
Max( IMG1, IMG2 )

Screen
~(~IMG1 * ~IMG2)

Color Dodge (non-commutative)
IMG1 / ~IMG2

Overlay (non-commutative)
iif( IMG1 > 0.5, ~(~(2*(IMG1 - 0.5)) * ~IMG2), 2*IMG1*IMG2 )

Soft Light (?) (non-commutative)
iif( IMG2 > 0.5, ~(~IMG1 * ~(IMG2 - 0.5)), IMG1*(IMG2 + 0.5) )

Hard Light (non-commutative)
iif( IMG2 > 0.5, ~(~IMG1 * ~(2*(IMG2 - 0.5))), 2*IMG1*IMG2 ) )

Vivid Light (??) (non-commutative)
iif( IMG2 > 0.5, ~(~IMG1/(IMG2 - 0.5)/2), IMG1/~(2*IMG2) )

Linear Light (non-commutative)
iif( IMG2 > 0.5, IMG1 + 2*(IMG2 - 0.5), IMG1 + 2*IMG2 - 1 )

Pin Light (non-commutative)
iif( IMG2 > 0.5, Max( IMG1, 2*(IMG2 - 0.5) ), Min( IMG1, 2*IMG2 ) )

Difference
IMG1 -- IMG2

Exclusion
0.5 - 2*(IMG1 - 0.5)*(IMG2 - 0.5)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Enzo De Bernardini

  • PTeam Member
  • PixInsight Addict
  • ***
  • Posts: 274
  • Resistance is futile.
    • Astronomí­a Sur
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #13 on: 2010 October 01 12:31:30 »
Quote
Knowing this you can simplify many of the expressions, and hence make them run faster.

Ahh, the Jedi Masters always see a little further. :D Cool.

I updated the Vivid Light with a new formula that worked, and added a screenshot with all the examples created.

Best,

Enzo.

Offline mmirot

  • PixInsight Padawan
  • ****
  • Posts: 881
Re: How to reproduce the various 'Blend' modes of PS in PixInsight?
« Reply #14 on: 2010 October 01 19:58:52 »
It would be great to have these as pre-set formulas somehow in Pixel math.
Just select the target images etc

Max