Bug 174177 - Proposal for implementing smart unsharp masking
Summary: Proposal for implementing smart unsharp masking
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Editor-Sharpen (show other bugs)
Version: 0.9.4
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-03 16:52 UTC by Dik Takken
Modified: 2023-04-06 15:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 8.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dik Takken 2008-11-03 16:52:40 UTC
Version:           0.9.4 (using KDE 3.5.10)
OS:                Linux
Installed from:    Gentoo Packages

There are two problems with plain unsharp masking:

* It amplifies noise
* It destroys image detail due to clipping of highlights and shadows

Both problems can be fixed by 'smart unshap masking'. 

The noise problem can be solved by masking the whole image, except for the edges. In the GIMP:

* Duplicate layer
* Use 'Edge' filter to find the edges in the image
* Convert to grayscale
* Apply gaussian blur to make smooth edges (slightly, 5 pixels or so)
* Apply levels to increase the contrast, this will influence noise suppression

Now you have a mask that you can use to combine the original image with the unsharp masked one. Only the areas that feature lots of detail will be unsharp masked.

The clipping problem can be solved by masking the highlights and shadows in the image. In the GIMP:

* Duplicate layer
* Convert to grayscale
* Use the Curves tool to make the shadows and highlights turn out black, the middle tones should be white. There should be a steep but smooth transition in between. The shadow and highlight thresholds depend on the image and the strength of unsharp masking.

There is another technique that cannot be done in the GIMP, but it could be implemented in DigiKam. It might yield better results and might be simpler to implement:

* Apply normal unsharp masking
* Create a mask from all pixels that are clipped after unsharp masking
* Blur the mask slightly, gives smooth transitions
* Now re-do the unsharp masking, using the mask to prevent clipping.

Currently, I apply the above two GIMP procedures manually. When I need 16-bit support, I apply them using ImageMagick. It would be great if DigiKam could add a 'noise suppression' and a 'protect shadows/highligts' option to its unsharp masking implementation, so these techniques can be applied automatically.
Comment 1 caulier.gilles 2023-04-06 15:42:48 UTC
The Image Editor GMIC-Qt etails/Unsharp Mask sounds like a good alternative which implements a better algorithms working on more colore space with plenty of highlight/darkness adjustements.

https://i.imgur.com/85ILMZP.png

Gilles Caulier