Bug 411863 - Artifacts appear when using HSV adjustments
Summary: Artifacts appear when using HSV adjustments
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Filters (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-12 14:45 UTC by acc4commissions
Modified: 2019-10-15 09:01 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
sample image (327.53 KB, image/jpeg)
2019-09-12 14:45 UTC, acc4commissions
Details
sample image 2 (5.74 KB, image/png)
2019-09-12 14:51 UTC, acc4commissions
Details

Note You need to log in before you can comment on or make changes to this bug.
Description acc4commissions 2019-09-12 14:45:54 UTC
Created attachment 122628 [details]
sample image

SUMMARY
git 535ca1f


STEPS TO REPRODUCE
1. Load an image, preferably the one has a white to darker color gradient.
2. Select 'HSL' type, and lower the lightness silder.

Similar artifacts appear when raising Saturation on HSL, HSI type.

SOFTWARE/OS VERSIONS
Windows:
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

System info : 

Krita

 Version: 4.3.0-prealpha (git 535ca1f)
 Languages: en_US
 Hidpi: false

Qt

  Version (compiled): 5.12.4
  Version (loaded): 5.12.4

OS Information

  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 6.1.7601
  Pretty Productname: Windows 7 SP 1 (6.1)
  Product Type: windows
  Product Version: 7sp1


Hardware Information

  GPU Acceleration: desktop
  Memory: 16351 Mb
  Number of Cores: 8
  Swap Location: C:/Users/(-----)/AppData/Local/Temp
Comment 1 acc4commissions 2019-09-12 14:51:47 UTC
Created attachment 122629 [details]
sample image 2

Tested with gradient tool.
Comment 2 Lynx3d 2019-09-12 20:20:06 UTC
I don't think there's anything you could do though, that's just how HSL works, both  hue and saturation are undefined for white and black RGB colors, and subject to low precision near white/black. So lowering lightness will turn tiny RGB differences into huge hue and saturation gaps.
White could be turned into a color with arbitrary hue and saturation with any choice being equally correct (or wrong, depending on point of view).
Comment 3 Ahab Greybeard 2019-09-13 16:05:32 UTC
The amount of apparent colour that comes in when lightness is reduced by a small amount is surprising,

Exactly the same result occurs when reducing Lightness with HSV adjustment in GIMP. I assume this is because they both use the same standard/accepted library functions.
Comment 4 Dmitry Kazakov 2019-09-17 09:41:29 UTC
Git commit 2f4353406a08249a1b91604298101b5384d91887 by Dmitry Kazakov.
Committed on 17/09/2019 at 09:40.
Pushed by dkazakov into branch 'kazakov/custom-hsv-filter'.

Test patch that "fixes" HSL transfgormation for white and black images

Basically, the transformation is substituted with HCL transformation,
but with clever sliding on the edges of the rhombus. I need people's
input, whether the transformation is still useful for painters.

Now it looks almost like "Hue/Saturation/Luma" (it also uses chroma
instead of saturation), but with a different approach to calculation
of 'L' channel :)

M  +94   -0    libs/pigment/KoColorConversions.cpp
M  +3    -0    libs/pigment/KoColorConversions.h
M  +19   -12   plugins/color/colorspaceextensions/kis_hsv_adjustment.cpp

https://invent.kde.org/kde/krita/commit/2f4353406a08249a1b91604298101b5384d91887
Comment 5 Dmitry Kazakov 2019-10-14 16:48:08 UTC
Git commit f68e3ef17af7ac913a657f7b5106894bc6a9acf0 by Dmitry Kazakov.
Committed on 14/10/2019 at 16:04.
Pushed by dkazakov into branch 'master'.

Fix HSL, HSV, HCI and HCY transformations for white and black images

Basically, the transformations are substituted with their chroma-based
counterparts, with clever sliding on the edges of the triangle.

The new filters behave a bit differently, therefore the patch adds
a "Compatibility Mode" switch for the filter. It enables old behavior.

M  +12   -8    libs/global/kis_global.h
M  +370  -75   plugins/color/colorspaceextensions/kis_hsv_adjustment.cpp
M  +13   -0    plugins/filters/colorsfilters/kis_hsv_adjustment_filter.cpp
M  +7    -0    plugins/filters/colorsfilters/wdg_hsv_adjustment.ui

https://invent.kde.org/kde/krita/commit/f68e3ef17af7ac913a657f7b5106894bc6a9acf0
Comment 6 Dmitry Kazakov 2019-10-14 16:48:08 UTC
Git commit 4cbf5ef4826b72bb13b8e1951f4df9cdf7124a82 by Dmitry Kazakov.
Committed on 14/10/2019 at 16:04.
Pushed by dkazakov into branch 'master'.

Fix backward compatibility for filter layers which don't have new keys

Some filter configurations (e.g. HSV-filter) expect that older configs
don't have newly introduced keys (e.g. "compatibilityMode"). Therefore
we shouldn't use default filter configuration as a source when loading
the layer. Instead, we should create a new one, and only then load.

M  +8    -6    plugins/impex/libkra/kis_kra_load_visitor.cpp
M  +2    -1    plugins/impex/libkra/kis_kra_load_visitor.h

https://invent.kde.org/kde/krita/commit/4cbf5ef4826b72bb13b8e1951f4df9cdf7124a82
Comment 7 Dmitry Kazakov 2019-10-15 09:01:46 UTC
The fix has been merged to master