Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 827721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:37:01+00:00 2026-05-15T03:37:01+00:00

I’ve been playing around with image processing lately, and I’d like to know how

  • 0

I’ve been playing around with image processing lately, and I’d like to know how the unsharp mask algorithm works. I’m looking at the source code for Gimp and it’s implementation, but so far I’m still in the dark about how it actually works. I need to implement it for a project I’m working on, but I’d like to actually understand the algorithm I’m using.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:37:02+00:00Added an answer on May 15, 2026 at 3:37 am

    I wasn’t sure how it worked either but came across a couple of really good pages for understanding it. Basically it goes like this:

    1. What’s the opposite of a sharpened image? A blurry one. We know how to blur an image. Duplicate the original image and perform some Gaussian blurring. This is the Radius slider on most USM dialogs.
    2. Well, if we subtract away the blurriness, we should be left with the parts that are high-contrast! Think about it: if you blur a sky, it still looks like a sky. Subtract the pixels and you get sky – sky = 0. If you blur a Coke logo, you get a blurry Coke logo. Subtract it and you’re left with the edges. So do the difference
    3. Well what makes things look sharper? Contrast. Duplicate the original image again and increase the contrast. The amount by which you increase the contrast is the Amount or Intensity slider on most USM dialogs.
    4. Finally put it all together. You have three things at this point:

      1. A high contrast version of your original image
      2. The difference of the blurred image and your original (this layer is mostly black). This layer is the unsharp mask
      3. The original

      The algorithm goes like this: Look at a pixel from the unsharp mask and find out its luminosity (brightness). If the luminosity is 100%, use the value from the high-contrast image for this pixel. If it is 0%, use the value from the original image for this pixel. If it’s somewhere in-between, mix the two pixels’ values using some weighting. Optionally, only change the value of the pixel if it changes by more than a certain amount (this is the Threshold slider on most USM dialogs).

    Put it all together and you’ve got your image!

    Here’s some pseudocode:

    color[][] usm(color[][] original, int radius, int amountPercent, int threshold) {
      // copy original for our return value
      color[][] retval = copy(original);
    
      // create the blurred copy
      color[][] blurred = gaussianBlur(original, radius);
    
      // subtract blurred from original, pixel-by-pixel to make unsharp mask
      color[][] unsharpMask = difference(original, blurred);
    
      color[][] highContrast = increaseContrast(original, amountPercent);
    
      // assuming row-major ordering
      for(int row = 0; row < original.length; row++) {
        for(int col = 0; col < original[row].length; col++) {
           color origColor = original[row][col];
           color contrastColor = highContrast[row][col];
    
           color difference = contrastColor - origColor;
           float percent = luminanceAsPercent(unsharpMask[row][col]);
    
           color delta = difference * percent;
    
           if(abs(delta) > threshold)
             retval[row][col] += delta;
        }
      }
    
      return retval;
    }
    

    Note: I’m no graphics expert, but this is what I was able to learn from the pages I found. Read them yourself and make sure you agree with my findings, but implementing the above should be simple enough, so give it a shot!

    References

    • Sharpening Using an Unsharp Mask
    • Understanding the Digital Unsharp Mask
    • 3.7 Unsharp Mask
    • Unsharp masking
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.