The Math Behind Photoshop's Unsharp Mask and Gaussian Blur

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

Drazick

The Math Behind Photoshop's Unsharp Mask and Gaussian Blur

Post by Drazick »

Hello,
Has anyone succeeded in reproducing Photoshop's Gaussian Blur and Unsharp Mask?

I have a technique to apply a really nice Local contrast Enhancer based on Unsharp Mask yet I have to reproduce Photoshop's first.
I reproduce Photoshop's Unsharp Mask using some math on layers and the Gaussina Blur.
Assuming 'O' is the layer we want to apply USM on then:

USM('O') = O + (O-GB) - inv(O + inv(GB))

Where GB stands for a Gaussian Blurred version of O.
Subtractions and Addition can be done using Photoshop's 'Apply Image' command.

As you can see this is not the "Classic" Unsharp Mask.

Has anyone reproduced it in C / Python / MATLAB?

P.S.
I know it is a bit off topic but I assume many people here are the right people to ask about it.
jcr6

The Math Behind Photoshop's Unsharp Mask and Gaussian Blur

Post by jcr6 »

easier way to do it is:

1) Duplicate the layer
2) use High Pass (at whatever radius you like)
3) change the layer mode to "Linear Light"

This adds a high pass on a Gaussian blur (of the given radius) back into the image. (Linear Light is addition).

You could also use Hard Light and get something more pleasing to look at.

Duplicating this layer can increase the effect to 200%, or reducing the opacity can lower it.
Drazick

The Math Behind Photoshop's Unsharp Mask and Gaussian Blur

Post by Drazick »

Hi,
I did as you suggested and didn't get the exact result of USM.

Am I missing something?