Formulas for Photoshop blending modes
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) * (1 – (1-Target) / (2*(Blend-0.5))) + (Blend <= 0.5) * (Target / (1-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) |