Bug 495329 - Incorrect gradient map behavior at high color depth with linear RGB
Summary: Incorrect gradient map behavior at high color depth with linear RGB
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: Filters (show other bugs)
Version: 5.2.6
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-25 03:36 UTC by Valerie Halla
Modified: 2024-10-25 09:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
The Krita file containing figures A, B, and C (see report). (2.22 MB, application/x-krita)
2024-10-25 03:36 UTC, Valerie Halla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Valerie Halla 2024-10-25 03:36:40 UTC
Created attachment 175209 [details]
The Krita file containing figures A, B, and C (see report).

Attached is a Krita document containing several example images. The document is RGBA, but the example images are grayscale, to make it easier to illustrate this bug. You'll have to open this file up in Krita and follow along to reproduce.

The paint layer containing FIGURE A has a GRADIENT MAP applied as a filter mask. This gradient map is a simple two-stop gradient from BLACK at 0% to WHITE at 100%. Because the layer is already grayscale, applying this gradient map to FIGURE A results in no visible change. This is good! That's the expected behavior.

Now go to IMAGE->CONVERT IMAGE COLOR SPACE. Set the DEPTH to "16-bit integer/channel" and the PROFILE to "sRGB-elle-V2-g10.icc" (this should be selected automatically when increasing the bit depth). Click OK.

EXPECTED BEHAVIOR: 
FIGURE A should appear completely unchanged, as in FIGURE B.

OBSERVED BEHAVIOR: 
FIGURE A appears altered with what seems to be an incorrect GAMMA CURVE, as in FIGURE C.

ADDITIONAL INFO:
Try toggling the gradient map off. You'll see that the underlying image has been correctly converted to the linear RGB color space. In other words, the problem is somewhere in the gradient map filter: it seems like it's failing to correctly map the input values onto the interpolated output values (if I may guess).

Now, try setting the bit depth back to "8-bit integer/channel", but set the profile to "sRGB-elle-V2-g10.icc". Note how the gradient map works as intended, despite the linear RGB color profile!

Next, set the bit depth back to "16-bit integer/channel", but set the profile to "sRGB-elle-V2-srgbtrc.icc". Note how the gradient map works as intended, despite the high bit-depth!

In other words, the problem appears to be with the COMBINATION of high bit-depth and linear RGB. To summarize:

8-bit, sRGB: Gradient map works as expected.
8-bit, linear RGB: Gradient map works as expected.
16-bit+, sRGB: Gradient map works as expected.
16-bit+, linear RGB: Gradient map misbehaves!
Comment 1 Halla Rempt 2024-10-25 06:47:05 UTC
Yes, gradients are calculated in 8 bit RGB -- this is not a bug, just a limitation.
Comment 2 Valerie Halla 2024-10-25 09:19:26 UTC
(In reply to Halla Rempt from comment #1)
> Yes, gradients are calculated in 8 bit RGB -- this is not a bug, just a
> limitation.

Here's is what confuses me, and why I feel this behavior specifically constitutes a bug: I could understand if "gradients are calculated in 8-bit RGB" meant "gradient maps don't work in higher bit depths", but they do--as long as the color profile is sRGB. I could also understand if it meant "gradient maps don't work in linear RGB", but they do--as long as the depth is 8-bit! It's only the *combination* of those two separate circumstances where gradient maps seem to misbehave, at least as far as I can see.