You are here

Math Behind Unsharp Mask

I looked at how Unsharp Mask is produced in GIMP according to this:

http://docs.gimp.org/en/plug-in-unsharp-mask.html

Yet, its result are poor compared to Photoshop's implementation.

I could reproduce Photoshop's effect using Gaussian Blur, Layer and Apply Image in Photoshop according to this:
http://www.lynda.com/Photoshop-tutorials/Building-your-own-USM-Gaussian-...

If you don't have Lynda user, just read the text below the video or follow these steps (In Photoshop):

To make it briefly, Assuming O is the original this is the way to recreate Unsharp Mask (The first word is the layer name, just create those names):

1. 'GB' - Create a duplicate of O, apply Gaussian Blur.
2. 'O-GB' - Duplicate the layer 'O'. Using 'Apply Image' subtract the layer 'GB'.
3. 'inv(GB)' - Duplicate 'GB' layer and invert it.
4. 'O+inv(GB)' - Duplicate 'O' layer and using 'Apply Image' add the 'inv(GB)' layer.
5. 'inv(O+inv(GB))' - Duplicate 'O+inv(GB)' and invert it.

Now, the Unsharp Mask of 'O' is given by 'O+(O-GB)-inv(O+inv(GB))'.
You can do that by 'Apply Image'.

Remembering inv(Layer) = 1 - Layer (I assume image is [0, 1) yields something interesting.
It means, at the end USM(O) = 3O - 2B.
This is quite strange.
Moreover, Trying to calculate 3'O' - 2'B' directly yields something different.

Yet this simple equation - 3 * O - 2 * B doesn't make sense to me.
Moreover, trying to implement it in MATLAB / Octave resulted in different results.

Am I missing something here mathematically?
Has anyone succeeded reproducing Photoshop's Gaussian Blur and Unsharp Mask outside of Photoshop (In a programming language).

I have idea how to improve which I'd like to make for Gimp yet I must reproduce it first.

P.S.
This post:
http://redskiesatnight.com/2005/04/06/sharpening-using-image-magick/
claims that GIMP is identical to Photoshop, Is it?

Taxonomy upgrade extras: 
Subscribe to Comments for "Math Behind Unsharp Mask"