-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sixel quality improvements #174
Comments
As mentioned in the discussion, there's currently no way for the user to get better quality. Let's use this issue for improvements to the default quantizer and ways to trade off work/quality with the |
Ideally, the palette should not be the same for every image, but rather tailored to each one. |
It does use a dynamic palette, but the palette generator isn't great for quality. I think it's possible to get better results without making performance suffer too much, though. |
Wow that cloud image is an interesting one, it also steps into an edge case in my octree impl cutting off too many of the "second line colors" during my 2nd-pass tree pruning. Thx for that image, a good test case indeed. |
I spent last weekend reimplementing the palette generator. It's much better now. I did some benchmarks using a new test script I wrote:
There's a lot of interesting information in that table. For instance, although the nominal palette size is ~255 colors, different approaches can end up producing a lot more or a lot fewer colors, and quality metrics don't always correlate well with subjective quality. |
In these tests, it's 24x as fast as IM and 3-4x as fast as ncplayer while producing top-tier output quality. |
very nice! |
@dankamongmen By the way - is there a way to invoke the Notcurses engine so that it replicates the input image dimensions precisely, and without doing a detection round-trip to the terminal? It'd make it much easier to run in a benchmarking harness and get fair results. I had to include it because it's one of the few well-performing implementations, but was in doubt because of the manual tweaking involved (plus I think some of the wall-clock time is spent waiting for the terminal to respond to queries). |
Discussed in #173
Originally posted by helma October 4, 2023
I intend to use chafa as a previewer for my photos, but have sometimes problems with the rendering quality of slow color gradients (e.g. cloudy skies), that come out very quantized with distinct color bands. Crisp photos render however perfectly as sixels. I have tried chafa, notcurses, img2sixel and imagemagick and in general I can get the best results with the -I option of img2sixel, followed by magick, notcurses and chafa (my terminal is foot version: 1.14.0 +pgo +ime +graphemes -assertions from nixos 23.05). Here are the resulting sixel files, png images have been generated with sixel2img:
Original (not very beautiful, but shows the effect very clearly):
chafa source.jpeg > chafa.six
(Chafa version 1.12.4)https://files.pdp8.info/chafa.six
ncplayer -t0 -q -k -s scalehi source.jpeg > notcurses.six
(ncplayer version 3.0.9)https://files.pdp8.info/notcurses.six
magick source.jpeg -resize 1914x1188> sixel:- > magick.six
(Version: ImageMagick 7.1.1-18 Q16-HDRI x86_64 8c6cdf58e:20230923 https://imagemagick.org)https://files.pdp8.info/magick.six
img2sixel -I -w 1914 source.jpeg > img2sixel.six
(img2sixel 1.10.3)Conversion to png spoils it completely, but img2sixel gives by far the best approximation of the original with the
-I
option.The high color option may cause however artefacts at the bottom of some images (maybe related to libsixel/libsixel#16).
https://files.pdp8.info/img2sixel.six
Are there any options in chafa to improve sixel rendering of photos? Dithering can improve the appearance of this file, but I loose details in sharper shots. I would prefer to use chafa over the other options because of speed and active maintainance.
The text was updated successfully, but these errors were encountered: