Results 1 to 13 of 13

Thread: Math Behind Unsharp Mask

  1. #1

    Math Behind Unsharp Mask

    Hello,
    I found this article:

    http://www.lynda.com/Photoshop-tutor...3/34451-4.html

    If you don't have a registered user, just read the transcript or see my description below.

    It shows how to produce the Unsharp Mask using Gaussian Blur.
    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.

    Is there something I'm missing?
    Maybe Photoshop is clipping in each step which makes the math no working?
    Last edited by Drazick; 27th April 2014 at 03:27 PM.

  2. #2

    Join Date
    May 2011
    Location
    SE Michigan
    Posts
    4,511
    Real Name
    wm c boyer

    Re: Math Behind Unsharp Mask

    Welcome new person, only one problem...your link doesn't want to work.

  3. #3

    Re: Math Behind Unsharp Mask

    Quote Originally Posted by chauncey View Post
    Welcome new person, only one problem...your link doesn't want to work.
    Hello,
    Thank for the welcoming note.

    I edited, it should work now.
    Though you can read my description, it has everything in it.

  4. #4
    IzzieK's Avatar
    Join Date
    Dec 2013
    Location
    Chesterfield, Missouri/Melbourne, Australia
    Posts
    17,827
    Real Name
    Izzie

    Re: Math Behind Unsharp Mask

    William addressed you as "new person" because you did not state your name. If you will kindly go to your profile, fill in your location and the name you wanted to be addressed as, it will be nice.

    One of these days you might want to be annoyed at someone calling you "Hey!" so please fill in your name???

    Thanks for the links. Obviously, this is a very good link even if one is not a member. It also talks of CS3 and that is OK too.

  5. #5

    Re: Math Behind Unsharp Mask

    Hi Izziek,
    Drazick would be great :-).

    Anyhow, I think it is a good link.
    But what I'm after is could it really be that USM(O) = 3*O - 2*B?
    Something doesn't add up here...

    Anyone?

  6. #6
    saea501's Avatar
    Join Date
    Apr 2014
    Posts
    91
    Real Name
    Bob

    Re: Math Behind Unsharp Mask

    It's probably just me but this strikes me as something only a Boolean script writer would be interested in. I'm not sure photographers would find this of interest.

    I've hand assembled programs when I was in college and even then it was about as fun as a visit to the dentist.

    But hey......I've certainly been wrong before.

  7. #7
    GrahamS's Avatar
    Join Date
    Apr 2012
    Location
    Hertfordshire, United Kingdom
    Posts
    480
    Real Name
    Graham Serretta

    Re: Math Behind Unsharp Mask

    Quote Originally Posted by Drazick View Post
    Hello,
    I found this article:

    http://www.lynda.com/Photoshop-tutor...3/34451-4.html

    If you don't have a registered user, just read the transcript or see my description below.

    It shows how to produce the Unsharp Mask using Gaussian Blur.
    Why?

  8. #8
    ajohnw's Avatar
    Join Date
    Aug 2012
    Location
    S, B'ham UK
    Posts
    3,337
    Real Name
    John

    Re: Math Behind Unsharp Mask

    I thought something that was easier to do with the GIMP would turn up eventually. Maybe PS can do it this way. It gives some idea what the degree of blur does anyway.

    http://clownfishcafe.blogspot.co.uk/...harpening.html

    It sort of explains why too.

    John
    -

  9. #9

    Re: Math Behind Unsharp Mask

    Quote Originally Posted by GrahamS View Post
    Why?
    Because knowing the math behind will allow me to improve its faults.

  10. #10
    Moderator Manfred M's Avatar
    Join Date
    Mar 2012
    Location
    Ottawa, Canada
    Posts
    22,262
    Real Name
    Manfred Mueller

    Re: Math Behind Unsharp Mask

    The material is based on the rather "long in the tooth" Photoshop CS3, which was released about seven years ago. There is simply no way of knowing if any of the more up-to-date versions of Photoshop have updated the algorithms or not.

    Lynda.com is a pay site (and I can see the tutorial because I am a subscriber).

    If you are interested in the topic, can I recommend that you read what most considered the definitive work on sharpening; Image Sharpening with Adobe Photoshop, Camera Raw and Lightroom by Bruce Frazer and Jeff Schewe?

  11. #11

    Re: Math Behind Unsharp Mask

    Hi,
    I need the math, not a guide.

    Anyhow, they haven't changed the USM algorithm for years.
    You can try by yourself and see it has the same result.

  12. #12

    Join Date
    Nov 2011
    Location
    Brisbane, Australia
    Posts
    1,107
    Real Name
    Tony Watts

    Re: Math Behind Unsharp Mask

    Drazick, I am late coming to this because I had to do a bit of reading first. You changed your notation slightly, which is a bit off-putting but I think the result makes sense.

    The way I understand it is this. The adjustment made during the sharpening process is to add a multiple of the difference between the actual image O and the Gaussian blur version of it, GB. The result should be

    USM(O) = O + a (O - GB),

    where a is a parameter representative the amount of sharpening. Your result is the same as this if you choose a = 2.

    Unless I have misunderstood, I do think this is a crude way of sharpening and it is time that somebody did some serious research on the process. Sharpening with the usual methods seems to work only when it is marginally needed.

  13. #13

    Re: Math Behind Unsharp Mask

    Hi TonyW,
    You're absolutely right.
    If you neglect "Clipping" to [0, 1] of each layer you get what you wrote.

    Namely, neglecting "Cliiping" the USM of Photoshop is:

    USM(O) = O + 2 * (Amount / 100) * (O - GB).

    Now, what's interesting is that the GB of Photoshop is approximated by Box Blur yet not in the classic way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •