RBA & AF Astrophotography

Formulas for Photoshop blending modes

Posted: April 21st, 2010

Do you want to apply one of the Photoshop blending modes to two images but using a PixelMath-like tool? Here's a list of the current Photoshop blending modes and their equivalent PixelMath formula that I could find. While some of the formulas are precisely what Photoshop does, others are just an approximated guess. Also, blending modes that cannot be achieved by a straight PixelMath operation - such as Luminosity, Hue or Color - are excluded.

The formulas below assume the pixels in the image have a numeric range between 0 and 1, which is the default in PixInsight

In most cases, in order to mimic Photoshop's behavior, the option "Rescaled" in PixInsight's PixelMath should be checked, particularly those modes that could generate out-of-range values. Some other times, it doesn't matter, such as in the Darken and Lighten modes.

Blend mode Commutativity Formula Addtl .info
Darken commutative min(Target,Blend)         
Multiply commutative Target * Blend         
Color Burn non-commutative 1 - (1-Target) / Blend         
Linear Burn commutative Target + Blend - 1         
Lighten commutative max(Target,Blend)         
Screen commutative 1 - (1-Target) * (1-Blend)         
Color Dodge non-commutative Target / (1-Blend)         
Linear Dodge commutative Target + Blend         
Overlay non-commutative (Target > 0.5) * (1 - (1-2*(Target-0.5)) * (1-Blend)) +
(Target <= 0.5) * ((2*Target) * Blend)
A combination of multiply and screen.Also the same as Hard Light commuted
Soft Light non-commutative (Blend > 0.5) * (1 - (1-Target) * (1-(Blend-0.5))) +
(Blend <= 0.5) * (Target * (Blend+0.5))
A combination of multiply and screen(The formula is only approximate)
Hard Light non-commutative (Blend > 0.5) * (1 - (1-Target) * (1-2*(Blend-0.5))) +
(Blend <= 0.5) * (Target * (2*Blend))
A combination of multiply and screen. Also the same as Overlay commuted
Vivid Light non-commutative (Blend > 0.5) * (Target / (1-2*(Blend-0.5))) +
(Blend <= 0.5) * (1 - (1-Target) / (2*Blend)) )
A combination of color burn and color dodge
Linear Light non-commutative (Blend > 0.5) * (Target + 2*(Blend-0.5)) +
(Blend <= 0.5) * (Target + 2*Blend - 1)
A combination of linear burn and linear dodge
Pin Light non-commutative (Blend > 0.5) * (max(Target,2*(Blend-0.5))) +
(Blend <= 0.5) * (min(Target,2*Blend)))
A combination of darken and lighten
Difference commutative | Target - Blend |         
Exclusion commutative 0.5 - 2*(Target-0.5)*(Blend-0.5)



david (Contact, Page), February 23rd, 2011, 9:33
I tried the 'overlay' method in pixelmath, and even substituting '*' for 'x', and 0.5 for 1/2 it throws an error!

RBA (Contact, Page), February 23rd, 2011, 23:32
David, I should've made clear that the expressions aren't meant to be entered exactly as I indicated. Each software may have a different syntax depending on their particular PixelMath implementation.

For PixInsight, it would be something like this:

(($T > 0.5) * 1 - (1-2*($T-0.5)) * (1-BI)) ($T <= 0.5) * (2*$T) * BI

Where BI is the blending image.
Also note that all the expressions that use "if..." are approximate.

PSpeed42 (Contact, Page), February 3rd, 2014, 16:17
Hi, your chart is very useful.

However, I think that the Exclusion equation may not be correct. If I manually plug values into it then I get different results than one photoshop is displaying.

On the other hand, I've had good results with:
(source*(1-dest)) (dest*(1-source))

Hope it helps.

Royi (Contact, Page), May 16th, 2014, 5:19
They have some different math:

I'm wondering which Linear Light is more close to Photoshop's.

RBA (Contact, Page), May 16th, 2014, 18:14
Hello Royi,
You can always apply each of the formulas and calculate differences.

Sage (Contact, Page), May 23rd, 2014, 18:16
Royi, they are same. If you open brackets, you'll find out that condition is redudant.

Rob (Contact, Page), August 12th, 2014, 20:49
Thanks for this Site and this page of Formulas. A Links-Page would be a useful addition, Astrophotography is such an interesting subject.

Here is a Page of Workflows for Image Processing you may find helpful.



Low Light Videos

RBA (Contact, Page), August 31st, 2014, 11:12
Thank you Rob. On a side note, the processing workflow in the Astrosurf page you mentioned is a bit "old fashioned".

oyster (Contact, Page), April 10th, 2015, 3:23
as for Linear Light, your charts says "(Blend > 0.5) * (Target 2*(Blend-0.5))

Vi (Contact, Page), August 14th, 2017, 12:31
The two Linear Light calculations mentioned in the comments are equivalent. In fact, the calculation shown in this page is unnecessary complicated, because Target 2*(Blend-0.5) is the same as Target 2*Blend -1. No case distinction necessary.

Warren Hatch (Contact, Page), January 25th, 2020, 6:55
Thanks Rogelio for this extremely helpful information.

But the Pinlight formula doesn't seem to be correct. Shouldn't it be:
(Blend > 0.5) * (Target / (1-2*(Blend-0.5)))

Warren Hatch (Contact, Page), January 25th, 2020, 8:12
Sorry RBA, I meant the Vivid Light formula in my last message.

Rogelio Bernal Andreo (Contact, Page), March 1st, 2020, 0:09
Thank you Warren! The list is almost 10 years old. I should probably revise it and update it. Thank you!!

NobodyUser (Contact, Page), March 30th, 2021, 7:04
How do you apply alpha correctly?

Billw (Contact, Page), April 10th, 2021, 15:31
I hope you will update this if required, it seems to be the only resource on the internet that simply lists the formulas, everywhere else has a partial list then text descriptions of the rest.

fsx (Contact, Page), June 7th, 2021, 22:13
Another vote for an update of the formulas, and it would be really nice if you could add some new ones Photoshop added in the meantime?

Sky (Contact, Page), August 11th, 2021, 16:13
How do i get formula for color blend? I really need it

Post a comment
Your name:
Email: (we don't share this!)
Your web site:  (if you have one)

(you have 1000 characters left)