Bug 290442 - Unsharp mask with radius less than 1.0 burns images
Summary: Unsharp mask with radius less than 1.0 burns images
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Editor-Sharpen (show other bugs)
Version: 2.4.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-02 21:10 UTC by Tap
Modified: 2016-06-29 20:09 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.3.0


Attachments
Image before sharpening (108.96 KB, image/jpeg)
2012-01-02 21:20 UTC, Tap
Details
Image after unsharp mask in digiKam 2.4.1, radius 0.3, amount 0.8, threshold 0 (156.79 KB, image/jpeg)
2012-01-02 21:22 UTC, Tap
Details
Image after unsharp mask in GIMP 2.6.11, radius 0.3, amount 0.8, threshold 0 (129.85 KB, image/jpeg)
2012-01-02 21:23 UTC, Tap
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tap 2012-01-02 21:10:36 UTC
Version:           2.4.1 (using KDE 4.5.5) 
OS:                Linux

When I try to use a radius less than 1 with the Unsharp mask method in the digiKam Image Editor, the image becomes noticeably brighter and shows channel clipping in bright areas. I do not know the math involved but the GIMP does not share this behavior -- it simply sharpens the image as requested.

I am using digiKam 2.4.1 but this bug was also evident in 1.9.0.

Reproducible: Always

Steps to Reproduce:
1. Select an image in the lighttable and press F4 to open the Image Editor

2. Go to Enhance > Sharpen...

3. Set the following parameters, for example:
   radius 0.3
   amount 0.8
   threshold 0.00

4. Click OK and compare the before and after images.

Actual Results:  
The image becomes noticeably brighter.

Expected Results:  
The image should become sharper on a fine scale, but not noticeably brighter.

OS: Linux (i686) release 2.6.32.41-smp
Compiler: gcc
Comment 1 Tap 2012-01-02 21:20:38 UTC
Created attachment 67358 [details]
Image before sharpening
Comment 2 Tap 2012-01-02 21:22:12 UTC
Created attachment 67359 [details]
Image after unsharp mask in digiKam 2.4.1, radius 0.3, amount 0.8, threshold 0
Comment 3 Tap 2012-01-02 21:23:03 UTC
Created attachment 67360 [details]
Image after unsharp mask in GIMP 2.6.11, radius 0.3, amount 0.8, threshold 0
Comment 4 caulier.gilles 2012-01-02 22:56:46 UTC
*** Bug 225491 has been marked as a duplicate of this bug. ***
Comment 5 Marcel Wiesweg 2012-05-21 16:35:28 UTC
The bug applies for any radius < 1. Reason is simple: The settings allow to specify a Double, while the BlurFilter only takes an Int for radius, so radius<1 is rounded to 0, which (not unexpectedly) fails.

The story goes beyond: We have two blur algorithms, a true Gaussian kernel and a much faster Canny-Deriche based blur from CImg, the latter used by default.

CImg accepts a floating-point radius, our gaussian blur does not. 

The gimp implementation
http://git.gnome.org/browse/gimp/plain/plug-ins/common/unsharp-mask.c?h=gimp-2-8
uses true gaussian blur for radius < 10, and has a gaussian blur which accepts floating-point radius.

So a solution for this bug may entail
- having a look at the Gaussian matrix creation in comparison to the Gimp code: use floating point radius?
- define the blurring algorithm situation: currently it is decided based on platform issues. At should IMO be possible to request true Gaussian, and the algorithm should be stored in the FilterAction history
- decide if we want true Gaussian blur for small radius as Gimp does, or if the Canny-deriche approximation is ok
- fix the trivial double-to-int bug
Comment 6 caulier.gilles 2014-09-02 13:52:13 UTC
Git commit 9454b520434618f0f323960d3aece2af9cbe9ef7 by Gilles Caulier.
Committed on 02/09/2014 at 13:51.
Pushed by cgilles into branch 'master'.

do not permit null value with raduis parameter from UnsharpMask tool
FIXED-IN: 4.3.0

M  +1    -1    libs/dimg/filters/sharp/sharpsettings.cpp

http://commits.kde.org/digikam/9454b520434618f0f323960d3aece2af9cbe9ef7