Bug 463585

Summary: Visible banding with gradient map filter, even on high bit depth canvas
Product: [Applications] krita Reporter: Kampidh <qampidh>
Component: Filter LayersAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR    
Version: 5.1.4   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Visible banding on gradient after the filter is applied
Original gradient before the filter is applied
Example krita document

Description Kampidh 2022-12-29 12:20:57 UTC
Created attachment 154877 [details]
Visible banding on gradient after the filter is applied

SUMMARY
Using Gradient Map filter (either from Filter > Map, or Filter Layer) produces a visible banding, even on a higher bit depth canvas (16bpc). Segment and Stop gradient produces the same result.


STEPS TO REPRODUCE
1. Create new document, preferably at 16bpc
2. Create a simple gradient (eg. Black -> White)
3. Add Gradient Map with a same gradient as before

OBSERVED RESULT
Visible banding occurred on the gradient (attached image)

EXPECTED RESULT
Gradient should be smooth, or at least as smooth as the original layer.

SOFTWARE/OS VERSIONS
Windows: 10 Pro 21H2
Qt Version: 5.12

ADDITIONAL INFORMATION
It seems like the Gradient Map filter is processed with 8-bit precision regardless of the canvas bit depth. This can be observed by picking up the color on the gradient. The original gradient have a smooth transition, while the filtered one will have a bigger steps.
Comment 1 Kampidh 2022-12-29 12:22:26 UTC
Created attachment 154878 [details]
Original gradient before the filter is applied
Comment 2 Kampidh 2022-12-29 12:24:57 UTC
Created attachment 154879 [details]
Example krita document

Try to toggle the Gradient Map filter layer on and off, then observe the gradient.
Comment 3 Halla Rempt 2023-01-04 10:53:44 UTC
Thank you for the report. I can confirm the issue.
Comment 4 Bug Janitor Service 2023-01-04 21:28:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1698
Comment 5 Invent Merge Service 2023-01-05 07:02:13 UTC
Git commit b9e615b1ff944c86b160232d9563570b511de3d1 by Merge Service, on behalf of Deif Lou.
Committed on 05/01/2023 at 07:01.
Pushed by merge-service into branch 'master'.

Fix issue with banding in the gradient map filter

Part-of: <https://invent.kde.org/graphics/krita/-/merge_requests/1698>

M  +16   -0    libs/pigment/KoColorSpace.h
M  +17   -1    libs/pigment/KoColorSpaceAbstract.h
M  +41   -0    plugins/color/lcms2engine/LcmsColorSpace.h
M  +12   -1    plugins/color/lcms2engine/colorspaces/rgb_u8/RgbU8ColorSpace.cpp
M  +1    -0    plugins/color/lcms2engine/colorspaces/rgb_u8/RgbU8ColorSpace.h
M  +6    -6    plugins/filters/gradientmap/KisGradientMapFilter.cpp

https://invent.kde.org/graphics/krita/commit/b9e615b1ff944c86b160232d9563570b511de3d1
Comment 6 Halla Rempt 2023-01-05 09:04:51 UTC
Git commit 58794306157146e0a40658554569d0f44d11db26 by Halla Rempt, on behalf of Deif Lou.
Committed on 05/01/2023 at 09:04.
Pushed by rempt into branch 'krita/5.1'.

Fix issue with banding in the gradient map filter

Part-of: <https://invent.kde.org/graphics/krita/-/merge_requests/1698>
(cherry picked from commit b9e615b1ff944c86b160232d9563570b511de3d1)

M  +16   -0    libs/pigment/KoColorSpace.h
M  +17   -1    libs/pigment/KoColorSpaceAbstract.h
M  +41   -0    plugins/color/lcms2engine/LcmsColorSpace.h
M  +12   -1    plugins/color/lcms2engine/colorspaces/rgb_u8/RgbU8ColorSpace.cpp
M  +1    -0    plugins/color/lcms2engine/colorspaces/rgb_u8/RgbU8ColorSpace.h
M  +6    -6    plugins/filters/gradientmap/KisGradientMapFilter.cpp

https://invent.kde.org/graphics/krita/commit/58794306157146e0a40658554569d0f44d11db26