Gradient smoothness, dithering
Hi,
I am currently doing a wallpaper in Inkscape, and I have noticed a strange thing about gradients : we can see the steps.
Some other guys have also noticed this problem : http://inkscape-forum.andreas-s.net/topic/109624 (may 2007)
The rendering is exactly the same in inkscape, png export and Firefox (and Chromium). I have tested in Safari (Mac), and it is fine (not 100% sure : fast test).
Creating the same gradient with GIMP is fine : playing with brightness and contrast helps (contrast to ~110 and adjust brightness). See this picture : http://xinfe.free.fr/gradient.png
After further investigation, I found out that when disabling the 'Dither' option, GIMP's result is exactly the same as Inkscape. So, is it possible to implement this feature for *.png exports (opt-in/out) ? Nice article : http://en.wikipedia.org/wiki/Dither#Digital_photography_and_image_processing
I know that it's nearly nothing, but I noticed it in my wallpaper, and it's annoying me, now...
Nevertheless, Inkscape is great !
Bye
Oooh, gradient dithering would be nice.
On Thu, Aug 19, 2010 at 10:00, Xinfe Ewalavir <ewalavir@...400...> wrote:
Hi,
I am currently doing a wallpaper in Inkscape, and I have noticed a strange thing about gradients : we can see the steps.
Some other guys have also noticed this problem : http://inkscape-forum.andreas-s.net/topic/109624 (may 2007)
The rendering is exactly the same in inkscape, png export and Firefox (and Chromium). I have tested in Safari (Mac), and it is fine (not 100% sure : fast test).
Creating the same gradient with GIMP is fine : playing with brightness and contrast helps (contrast to ~110 and adjust brightness). See this picture : http://xinfe.free.fr/gradient.png
After further investigation, I found out that when disabling the 'Dither' option, GIMP's result is exactly the same as Inkscape. So, is it possible to implement this feature for *.png exports (opt-in/out) ? Nice article : http://en.wikipedia.org/wiki/Dither#Digital_photography_and_image_processing
I know that it's nearly nothing, but I noticed it in my wallpaper, and it's annoying me, now...
Nevertheless, Inkscape is great !
Bye
This SF.net email is sponsored by
Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Xinfe Ewalavir wrote:
... After further investigation, I found out that when disabling the 'Dither' option, GIMP's result is exactly the same as Inkscape. So, is it possible to implement this feature for *.png exports (opt-in/out) ? Nice article : http://en.wikipedia.org/wiki/Dither#Digital_photography_and_image_processing
In the past I tried this (in fact, I still have some code lying around to do part of this in Inkscape), but it has a few problems in Inkscape. First of all, file size is really increased considerably. This might not be a big problem in some cases, but is a good reason to at least not make it the default. Secondly, you're basically adding noise to your gradient that can become visible under certain circumstances. Again not something that's always an issue, but still.
So frankly I'd be more inclined to push for 16 bit (per channel) rendering in Inkscape and either dither the whole image at the end or simply save as 16 bit per channel and let the image viewer worry about dithering and such. These options will both give (much) higher quality results than just dithering an individual gradient and mostly avoid the above.
In any case, work is currently underway to change to using Cairo for rendering in Inkscape, so once that is done I guess this will have to be reevaluated (and I expect/hope that gradients will be handled by Cairo, so any changes would have to be made there).
2010/8/19 Jasper van de Gronde <th.v.d.gronde@...528...>:
In any case, work is currently underway to change to using Cairo for rendering in Inkscape, so once that is done I guess this will have to be reevaluated (and I expect/hope that gradients will be handled by Cairo, so any changes would have to be made there).
That's true. If anyone wants to investigate gradient dithering or 16-bit color, it's best to work on adding it to Pixman - the software compositing library used by Cairo.
Regards, Krzysztof
simply save as 16 bit per channel and let the image viewer worry about
If we're concerned about filesize, wouldn't this be even worse than a bit of dithering?
Not opposed to 16-bit rendering (I love high quality as much as anyone!), but given that I use Inkscape mostly for exporting for the web, it's not high on my priorities, either.
- Bryan
Even for the web, 16 bit per channel is needed to improve the smoothness of svg filters rendering.
ivan
________________________________ De : Bryan Hoyt | Brush Technology <bryan@...2310...> À : Jasper van de Gronde <th.v.d.gronde@...528...> Cc : inkscape-devel@lists.sourceforge.net Envoyé le : Jeu 19 août 2010, 23h 24min 28s Objet : Re: [Inkscape-devel] Gradient smoothness, dithering
simply save as 16 bit per channel and let the image viewer worry about
If we're concerned about filesize, wouldn't this be even worse than a bit of dithering?
Not opposed to 16-bit rendering (I love high quality as much as anyone!), but given that I use Inkscape mostly for exporting for the web, it's not high on my priorities, either.
- Bryan
Bryan Hoyt | Brush Technology wrote:
simply save as 16 bit per channel and let the image viewer worry about
If we're concerned about filesize, wouldn't this be even worse than a bit of dithering?
Apparently you're right, I just expanded my test program to also output 16 bit and get the following results (output is ppm, converted to png using imagemagick and optimized using pngcrush, both using the default settings): - 8 bit undithered: 40.3 KB - 8 bit dithered: 241 KB (6x) - 16 bit undithered: 418.7 KB (10x) - 16 bit dithered: 656.0 KB (16x) This is using triangular dither (random) and on just one example (a circular gradient used in an about screen a while ago), so take the results with the obligatory grain of salt.
Two things are interesting in these numbers, first of all you're right that 16 bit rendering takes even more space, secondly the difference dither makes likely depends on how "steep" the original gradient was, as it makes much less difference in the 16 bit case (where the gradient is steeper, relative to the smallest representable value).
So perhaps it is a good idea to add dither after all... But where? Dithering gradiens themselves is definitely not always a good idea (as I explained earlier this can wreak havoc, especially with filters), but dithering afterwards might not always be desired either (as it might dither more than is needed/desired, shapes with constant color for example).
I guess there are some interesting things to be done in this area, but in the short term it might be easiest to either try to enable 16 bit rendering and add dither afterwards or to add a simple dither to gradient rendering (would definitely need to be optional, possibly on a per-shape basis). This should probably be done in Cairo or pixman though (not sure which takes care of gradient rendering).
2010/8/20 Jasper van de Gronde <th.v.d.gronde@...528...>:
I guess there are some interesting things to be done in this area, but in the short term it might be easiest to either try to enable 16 bit rendering and add dither afterwards or to add a simple dither to gradient rendering (would definitely need to be optional, possibly on a per-shape basis).
Dithering would be much simpler to add, as Pixman doesn't support 16-bit compositing at the moment. It could be set as one of the pattern options.
By the way, 16-bit sRGB integers aren't the only option. 16-bit linear floats could be better.
Regards, Krzysztof
Krzysztof Kosiński wrote:
2010/8/20 Jasper van de Gronde <th.v.d.gronde@...528...>:
I guess there are some interesting things to be done in this area, but in the short term it might be easiest to either try to enable 16 bit rendering and add dither afterwards or to add a simple dither to gradient rendering (would definitely need to be optional, possibly on a per-shape basis).
Dithering would be much simpler to add, as Pixman doesn't support 16-bit compositing at the moment. It could be set as one of the pattern options.
By the way, 16-bit sRGB integers aren't the only option. 16-bit linear floats could be better.
Floats are VERY nice, and I'd love some HDR extensions to SVG. But in this specific case 16 bit floats are not that useful, as currently our "signals" stay within the range [0,1] and we'd probably be better off with more bits fixed precision than with a larger range (although I guess 16 bit floats may just have enough extra precision to work adequately with dithering).
participants (5)
-
Bryan Hoyt | Brush Technology
-
Ivan Louette
-
Jasper van de Gronde
-
Krzysztof Kosiński
-
Xinfe Ewalavir