Banding in SVG-filters with color-interpolation-filters=linearRGB
Reported by
dominik....@gmail.com,
Jun 30 2016
|
||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 Steps to reproduce the problem: 1. Open testcase: http://codepen.io/dom1n1k/pen/Lkyypm?editors=1100 2. Scroll to color-interpolation-filters="linearRGB" example 3. There are bands What is the expected behavior? Smooth gradient (or minor, almost invisible bands) What went wrong? Obvious bands Did this work before? N/A Chrome version: 51.0.2704.106 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: Shockwave Flash 22.0 r0 In the testcase filter change brightness as example. However, similar effect is observed with other filters (contrast, grayscale, etc). The matter in the interpolation mode 'linearRGB'. I suspect incorrect rounding in the last 3 rows: R[sRGB] = R[sRGB-8bit] / 255 G[sRGB] = G[sRGB-8bit] / 255 B[sRGB] = B[sRGB-8bit] / 255 If R[sRGB], G[sRGB], B[sRGB] <= 0.04045 R[linearRGB] = R[sRGB] / 12.92 G[linearRGB] = G[sRGB] / 12.92 B[linearRGB] = B[sRGB] / 12.92 else if R[sRGB], G[sRGB], B[sRGB] > 0.04045 R[linearRGB] = ((R[sRGB] + 0.055) / 1.055) ^ 2.4 G[linearRGB] = ((G[sRGB] + 0.055) / 1.055) ^ 2.4 B[linearRGB] = ((B[sRGB] + 0.055) / 1.055) ^ 2.4 R[linearRGB-8bit] = R[linearRGB] * 255 G[linearRGB-8bit] = G[linearRGB] * 255 B[linearRGB-8bit] = B[linearRGB] * 255 (Quote from the specification https://www.w3.org/TR/SVG/single-page.html#painting-ColorInterpolationProperties) Thanks And sorry for my bad english
,
Jul 1 2016
Screenshot
,
Jul 1 2016
Thank you for providing more feedback. Adding requester "msrchandra@chromium.org" for another review and adding "Needs-Review" label for tracking. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jul 12 2016
@dominik.md -- Verified the issue on Chrome, but I am also seeing the same behavior on Firefox also. Could you please confirm. Thanks in Advance.
,
Jul 12 2016
Yes, Firefox is buggy too :) Premature rounding (I guess) However iOS Safari looks better.
,
Jul 12 2016
Thank you for providing more feedback. Adding requester "msrchandra@chromium.org" for another review and adding "Needs-Review" label for tracking. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jul 15 2016
Verified the issue on Latest Stable# 51.0.2704.106 and Latest Canary# 54.0.2797.0 on Windows, Mac and Linux and was able to reproduce the issue. This is a Non-Regression issue seen from M30# 30.0.1599.101 (Official Build 227552) m. Attaching a screenshot comparing Chrome nad Safari. Firefox is also showing the same behavior as Chrome. Changing the status to Untriaged so that the issue would get addressed. Thank You.
,
Jul 15 2016
,
Jul 15 2016
I think this is a Skia issue. But I'll verify.
,
Jul 15 2016
+senorblanco who is most familiar with filter effects. Also a repro with no-op filters: http://codepen.io/anon/pen/groZpz I don't think there's anything wrong with the conversion LUT, but going into 8bit linear and then back to 8bit SRGB reduces the darker tones color resolution (which our eyes are most sensitive to - https://macman860.wordpress.com/2013/02/05/bit-depth-linear-light/). The solution is more bits per component (I'm assuming that's how Safari works), and there's work going on in Skia to add just that (float32/float16 pipeline w/ color correction). When that's complete, it should be possible to flip between linear/srgb without noticeable loss of color resolution.
,
Jul 15 2016
I can definitely see this happening if we do a smooth gradient in one space then convert to another that expands the dark tones, hence increasing the color difference between neighboring pixels. fmalita@ caught me not thinking when I triaged this. This seems to be a Skia issue at heart, so I'll add that component. Who's doing the Skia work? They should own the bug.
,
Jul 15 2016
+Brian#2, Mike#2
,
Jul 15 2016
Sure looks like iOS Safari is just treating "linearRGB" as "sRGB". Note how dark it is above the teal on the right edge of the iOS screenshot.
,
Jul 15 2016
Agreed. Note that there really isn't anything that can be done (other than dithering or 10-bit output, which 99% of users don't have) to make this look better. The "good" looking images look good because the bands are uniformly distributed. That makes sense - we're interpolating in sRGB, which is the display space. But for linear, we're interpolating in a non-linear space, so the resulting bands are non-uniformly distributed after conversion back to sRGB (for output). I claim that the behavior in this case is "correct" (doing what the user asked), even if it's less visually pleasing.
,
Jul 15 2016
@brianosman not sure I follow this bit: "there really isn't anything that can be done (other than dithering or 10-bit output". Looking at the simplified http://codepen.io/anon/pen/groZpz, what we're seeing is the effect of running all colors through c' = LinearToSRGB(SRGBToLinear(c)) I.e. the filter should be a no-op, but, due to 8bit/component quantization, it isn't. But if we increase the component resolution for the pipeline and all intermediate buffers (say to F16), then the banding artifacts would go away - or am I missing something?
,
Jul 15 2016
No, this isn't correct. What's happening: input sRGB image -> to linearRGB -> rounding to uint8 -> filter -> rounding to uint8 -> to sRGB -> rounding to uint8 Expectation: input sRGB image -> to linearRGB -> filter -> to sRGB -> rounding to uint8
,
Jul 15 2016
Sorry - we were misunderstanding what the filter itself was doing. The results make much more sense now. In particular: 1) Safari is ignoring "linearRGB". Note that even when applying the 50% brightness filter, it produces the same results as sRGB, which it shouldn't. 2) Edge (just to check) appears to ignore the filter entirely, so it's hard to tell how it treats the linearRGB vs sRGB. (The 50% version is still full brightness). 3) We are, in fact, quantizing to 8 bits while we're in linear, leading to the additional banding. The image filter pipeline in Skia does have this behavior (on both CPU and GPU), and fixing that would be a longer-term project, involving some combination of: - Using F16 during filtering. - Detecting filters that can/will be be applied in a single step, and using sRGB-tagged buffers.
,
Jul 15 2016
> Safari is ignoring "linearRGB" Hm, yes. I hadn't noticed it before.
,
Jul 17 2017
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jul 17 2017
,
Sep 14 2017
It's also not working for me on chrome 62 (unstable). Also this happens when I use CSS linear-gradient.
,
Sep 14 2017
That's expected. To my knowledge no one has done anything to change this.
,
Sep 17
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Sep 17
|
||||||||||||||
►
Sign in to add a comment |
||||||||||||||
Comment 1 by msrchandra@chromium.org
, Jul 1 2016Labels: Needs-Feedback