Bug 329945 - Improve UnsharpenMask Filter
Summary: Improve UnsharpenMask Filter
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Filters (show other bugs)
Version: git master (please specify the git hash!)
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-14 08:38 UTC by Paul Geraskin
Modified: 2014-03-15 08:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Geraskin 2014-01-14 08:38:49 UTC
Hi guys.

Blur and Sharpen filters are vital for every artist. They are used mostly. 
UnsharpenMask Filter has some issues:
- Radius Values is set as Integer. But it should be as Float (like in Gmic/Gimp)
- Transparent layer is not applied for the unsharpen mask.
- the result a bit different like in Gimp/GMic

Here is my screenshots explanation:
http://i.imgur.com/lVSAFFC.png - Unsharpen mask compared to Krita and Gimp
http://i.imgur.com/JBaXlmZ.png - test in GMic

Thanks.
Comment 1 Paul Geraskin 2014-01-14 08:40:10 UTC
Here is the file used for testing https://dl.dropboxusercontent.com/u/26887202/Krita/test_UnsharpenMask.psd
Comment 2 Dmitry Kazakov 2014-01-16 12:54:37 UTC
Git commit fe7b1bebcbc8bb5dcbc6f4d2d6e2a7a9c553e5a7 by Dmitry Kazakov.
Committed on 16/01/2014 at 12:36.
Pushed by dkazakov into branch 'krita-testing-kazakov'.

Fixed the Unsharp Mask filter

Now it has the following features:
1) Uses Gaussian for the initial blurring instead of home-grown
   circle mask
2) Supports floating point Radius value
3) Fixed the bug with wrong channelFlags are feed to the blur algo.
   They didn't contain alpha channel before, resulting in really weird
   results generated.
4) Uses Luminocity masking instead of mixing colors directly in RGB

M  +48   -0    krita/image/kis_gaussian_kernel.cpp
M  +8    -0    krita/image/kis_gaussian_kernel.h
M  +3    -47   krita/plugins/filters/blur/kis_gaussian_blur_filter.cpp
M  +90   -52   krita/plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +15   -0    krita/plugins/filters/unsharp/kis_unsharp_filter.h
M  +3    -3    krita/plugins/filters/unsharp/kis_wdg_unsharp.cpp
M  +13   -10   krita/plugins/filters/unsharp/wdgunsharp.ui

http://commits.kde.org/calligra/fe7b1bebcbc8bb5dcbc6f4d2d6e2a7a9c553e5a7
Comment 3 Dmitry Kazakov 2014-01-16 12:54:38 UTC
Git commit 342c679d77aafd03fae279ddb80608dd23aa0f68 by Dmitry Kazakov.
Committed on 16/01/2014 at 12:53.
Pushed by dkazakov into branch 'krita-testing-kazakov'.

Added a UI option for the LightnessOnly parameter of the Unsharp Mask filter

Also renamed half-size into more common 'radius'

M  +1    -0    krita/plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +3    -0    krita/plugins/filters/unsharp/kis_wdg_unsharp.cpp
M  +59   -45   krita/plugins/filters/unsharp/wdgunsharp.ui

http://commits.kde.org/calligra/342c679d77aafd03fae279ddb80608dd23aa0f68
Comment 4 Paul Geraskin 2014-01-16 14:17:08 UTC
Issues:
-Filter still not fixed. It does not work for one color with alpha. I sent the psd image to Dmitry.
-And the algorthm is not like in gmic/gimp. :(

Here is the screenshot with krita and gmic filtering:
http://i.imgur.com/wH3629Y.png

NOTE: GMIC FILTERING HAS 2 OPTIONS. Gaussian and Bilateral sharpening. 
Dmitry can you check it?

Thanks.
Comment 5 Paul Geraskin 2014-01-16 14:39:52 UTC
Yeah, sometimes filter works like Bevel/Bump filter.
http://i.imgur.com/eeCGx2A.png
Comment 6 Dmitry Kazakov 2014-01-16 19:37:22 UTC
Git commit 96053031e9366faea37df9639cc7c1643160c41a by Dmitry Kazakov.
Committed on 16/01/2014 at 19:32.
Pushed by dkazakov into branch 'master'.

Fix Unsharp Mask filter on semi-transparent images

This patch also adds KoColorSpace::differenceA() method that
works like its difference() counterpart, but also takes alpha
channel into account.

M  +1    -1    krita/plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +7    -0    libs/pigment/KoColorSpace.h
M  +5    -0    libs/pigment/colorspaces/KoAlphaColorSpace.cpp
M  +1    -0    libs/pigment/colorspaces/KoAlphaColorSpace.h
M  +7    -0    libs/pigment/colorspaces/KoSimpleColorSpace.h
M  +41   -3    plugins/colorengines/lcms2/LcmsColorSpace.h

http://commits.kde.org/calligra/96053031e9366faea37df9639cc7c1643160c41a
Comment 7 Dmitry Kazakov 2014-01-16 20:30:25 UTC
Some bug is still there...

http://i.imgur.com/zzNk0nz.png
Comment 8 Dmitry Kazakov 2014-01-24 07:57:08 UTC
Git commit f5f3eb1fedc65bd211f67c46a7748980d22c364f by Dmitry Kazakov.
Committed on 16/01/2014 at 19:32.
Pushed by dkazakov into branch 'calligra/2.8'.

Fix Unsharp Mask filter on semi-transparent images

This patch also adds KoColorSpace::differenceA() method that
works like its difference() counterpart, but also takes alpha
channel into account.

M  +1    -1    krita/plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +7    -0    libs/pigment/KoColorSpace.h
M  +5    -0    libs/pigment/colorspaces/KoAlphaColorSpace.cpp
M  +1    -0    libs/pigment/colorspaces/KoAlphaColorSpace.h
M  +7    -0    libs/pigment/colorspaces/KoSimpleColorSpace.h
M  +41   -3    plugins/colorengines/lcms2/LcmsColorSpace.h

http://commits.kde.org/calligra/f5f3eb1fedc65bd211f67c46a7748980d22c364f
Comment 9 Dmitry Kazakov 2014-01-24 07:58:28 UTC
Git commit 292adf4ca00a1500b1010277a5345850397f24d5 by Dmitry Kazakov.
Committed on 16/01/2014 at 12:36.
Pushed by dkazakov into branch 'calligra/2.8'.

Fixed the Unsharp Mask filter

Now it has the following features:
1) Uses Gaussian for the initial blurring instead of home-grown
   circle mask
2) Supports floating point Radius value
3) Fixed the bug with wrong channelFlags are feed to the blur algo.
   They didn't contain alpha channel before, resulting in really weird
   results generated.
4) Uses Luminocity masking instead of mixing colors directly in RGB

M  +48   -0    krita/image/kis_gaussian_kernel.cpp
M  +8    -0    krita/image/kis_gaussian_kernel.h
M  +3    -47   krita/plugins/filters/blur/kis_gaussian_blur_filter.cpp
M  +90   -52   krita/plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +15   -0    krita/plugins/filters/unsharp/kis_unsharp_filter.h
M  +3    -3    krita/plugins/filters/unsharp/kis_wdg_unsharp.cpp
M  +13   -10   krita/plugins/filters/unsharp/wdgunsharp.ui

http://commits.kde.org/calligra/292adf4ca00a1500b1010277a5345850397f24d5
Comment 10 Paul Geraskin 2014-01-24 09:14:43 UTC
Dmitry sorry me again.

But UnsharpenMask still does not work as expected. :(
Here is the test: http://i.imgur.com/w4bDI4G.png

Here is the file: https://dl.dropboxusercontent.com/u/26887202/Krita/test_UnsharpenMask4.psd
Comment 11 Dmitry Kazakov 2014-03-13 17:03:56 UTC
Git commit ce9346571c140a4f04cbfbee0447dab41f3147a0 by Dmitry Kazakov.
Committed on 13/03/2014 at 17:02.
Pushed by dkazakov into branch 'master'.

Fixed the Unsharp Mask filter to not be applied with an offset

Our gaussian kernel had a small offset which resulted in the difference
in the Unsharp Mask filter being calculated wrongly.

M  +14   -2    krita/image/kis_gaussian_kernel.cpp
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_10_10_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_10_10_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_15_15_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_15_15_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_5_5_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_5_5_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_10_10_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_10_10_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_15_15_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_15_15_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_5_5_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_5_5_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_10_10_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_10_10_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_15_15_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_15_15_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_5_5_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_5_5_spatial.png.png
M  +1    -1    krita/plugins/filters/unsharp/CMakeLists.txt
A  +10   -0    krita/plugins/filters/unsharp/tests/CMakeLists.txt
A  +-    --    krita/plugins/filters/unsharp/tests/data/source_with_transparency.png
A  +-    --    krita/plugins/filters/unsharp/tests/data/unsharp_mask_test/with_transparency_unsharp_with_transparency.png
A  +67   -0    krita/plugins/filters/unsharp/tests/kis_unsharp_mask_test.cpp     [License: GPL (v2+)]
A  +31   -0    krita/plugins/filters/unsharp/tests/kis_unsharp_mask_test.h     [License: GPL (v2+)]

http://commits.kde.org/calligra/ce9346571c140a4f04cbfbee0447dab41f3147a0
Comment 12 Dmitry Kazakov 2014-03-13 17:05:00 UTC
I hope the bug is now finally fixed :)
Comment 13 Paul Geraskin 2014-03-14 05:50:06 UTC
YES YES YES!!! YOU FIXED IT!!!! KRITA HAS PRO SHARPEN TOOLS!!!!!!! 
СПАСИБО БОЛЬШОЕ!!!!!!!!!!

http://i.imgur.com/rwSE7As.png
http://i.imgur.com/n0Jx1vw.png
Comment 14 Dmitry Kazakov 2014-03-15 08:27:00 UTC
Git commit ae5b6bd07e918a1f8f4deb64f00f7a52db20c774 by Dmitry Kazakov.
Committed on 13/03/2014 at 17:02.
Pushed by dkazakov into branch 'calligra/2.8'.

Fixed the Unsharp Mask filter to not be applied with an offset

Our gaussian kernel had a small offset which resulted in the difference
in the Unsharp Mask filter being calculated wrongly.

M  +14   -2    krita/image/kis_gaussian_kernel.cpp
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_10_10_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_10_10_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_15_15_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_15_15_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_5_5_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian__test_gaussian_5_5_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_10_10_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_10_10_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_15_15_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_15_15_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_5_5_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_details_test_gaussian_5_5_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_10_10_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_10_10_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_15_15_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_15_15_spatial.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_5_5_fftw.png.png
M  +-    --    krita/image/tests/data/convolution_painter_test/gaussian_reduced_test_gaussian_5_5_spatial.png.png
M  +1    -1    krita/plugins/filters/unsharp/CMakeLists.txt
A  +10   -0    krita/plugins/filters/unsharp/tests/CMakeLists.txt
A  +-    --    krita/plugins/filters/unsharp/tests/data/source_with_transparency.png
A  +-    --    krita/plugins/filters/unsharp/tests/data/unsharp_mask_test/with_transparency_unsharp_with_transparency.png
A  +67   -0    krita/plugins/filters/unsharp/tests/kis_unsharp_mask_test.cpp     [License: GPL (v2+)]
A  +31   -0    krita/plugins/filters/unsharp/tests/kis_unsharp_mask_test.h     [License: GPL (v2+)]

http://commits.kde.org/calligra/ae5b6bd07e918a1f8f4deb64f00f7a52db20c774