Bug 412491

Summary: Color Adjustment curves can give incorrect result
Product: [Applications] krita Reporter: M <manuel.snudl.zeidler>
Component: FiltersAssignee: vanyossi <ghevan>
Severity: normal CC: ghevan, griffinvalley, tamtamy.tymona
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Test file with buggy filter

Description M 2019-09-30 22:52:40 UTC
When positioning the end handles of any channel curve so that the numeric values are exactly Input = Output, effectively clipping the output range without changing in-between values, the filter behaves like the curve hasn't been adjusted at all.

1. Open Filter > Adjust > Color Adjustment curves... and pick any channel
2. Reposition the first end handle of the default linear curve and make sure the value of the Input exactly matches the Output - for example to 127, 127 on an 8-bit image to clip the lower half of the values
3. Add +/- 1 to the input and observe the immediate difference

The adjusted result is identical to the untouched linear curve.

The values beyond the end handles should be clipped in the adjusted image.

Tested in 4.3.0-prealpha (git 511ecc7) and 4.2.6, resulting in the same behavior.

Inserting additional curve nodes that also conform to Input = Output won't affect the result either.
Comment 1 Tiar 2019-10-01 18:05:13 UTC
I can't reproduce; can you please attach a file to see the results and the screenshot of your filter settings? Or maybe a .kra file with a filter layer or mask if it shows the issue, too.
Comment 2 M 2019-10-01 23:02:21 UTC
Created attachment 122970 [details]
Test file with buggy filter

Here you go. The top layer is the Color Adjustment, and despite having crushed RGBA towards the middle and Red towards the brightest values, the image appears unaltered. When you open the layer properties and tweak the curves by a tiny amount, the adjustment turns visible.
Comment 3 Bug Janitor Service 2019-10-02 04:33:12 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 4 wolthera 2019-10-07 15:35:39 UTC
Yeah, I can confirm with that image. I wonder if there's some kind of optimization or something doing this? I can see there's one for identity curves(KisPerChannelFilter::createTransformation 207), but is this really an identity curve?
Comment 5 vanyossi 2019-10-12 06:30:54 UTC
identity seems to be added for optimization, to avoid calculating in extreme cases. However all it does is checking all curve points p, have the corrdinates (x,x). which makes the results wrong in cases were the extremes are not min/max respectively.

REmoving the identity check solves the issue and should not give any error, but the "special case" will not be optimized.
Comment 6 vanyossi 2019-10-15 07:38:17 UTC
Git commit 8b1ac0f6d645ba87502b8ccb471246fac9231b01 by Ivan Yossi.
Committed on 14/10/2019 at 17:27.
Pushed by rempt into branch 'master'.

Fix Color Adjustment Curves not processing on some cases

isIdentity will only resolve to true if the corners are placed
in the corners and the middle points are all x = y

M  +7    -2    libs/image/kis_cubic_curve.cpp

Comment 7 Halla Rempt 2019-10-21 12:59:49 UTC
Git commit bfd110a3a51385d57e1dd2aea8b73ead0053b37a by Boudewijn Rempt, on behalf of Ivan Yossi.
Committed on 21/10/2019 at 12:58.
Pushed by rempt into branch 'krita/4.2'.

Fix Color Adjustment Curves not processing on some cases

isIdentity will only resolve to true if the corners are placed
in the corners and the middle points are all x = y
(cherry picked from commit 8b1ac0f6d645ba87502b8ccb471246fac9231b01)

M  +7    -2    libs/image/kis_cubic_curve.cpp