Open kornelski opened 8 years ago
Coincidentally the next version of WebP will solve that too, by using an iterative algorithm:
https://chromium.googlesource.com/webm/libwebp/+/master/src/enc/picture_csp.c#487
That prototype is pretty impressive. It's far better than the current subsampling.
Edit: I made a little comparison slider. The image on the right is the prototype:
The webp source code link moved to https://github.com/webmproject/libwebp/blob/master/src/enc/picture_csp_enc.c. Search PreprocessARGB
for the iterative code. As Ser-Gen memntioned, sjpeg calls this scaling "sharp YUV". https://github.com/webmproject/sjpeg/blob/5ce9c14cceba85a83ac6efcef94658eb28e304ea/src/yuv_convert.cc#L101
The luma-scaled code is at https://github.com/kornelski/jpeg-compressor/blob/9eeb009fdb8673224de5be978574cb139e4b8bf6/jpge.cpp#L611.
sharp YUV is now a separate libsharpyuv
in the webp project, with its own pkg-config
file and everything. It is an optional choice in AVIF.
Huh, apparently there's yet another approach , the HDRTools way. Pic is from doi:10.5594/m001639. No idea how well it works in SDR, when "OETF" is just "gamma".
Oh god a google for "chroma subsampling" gave me some arxiv magic (possible published version) involving gradient descent in H.266. oh it's friendlier when you say "iterative" and it lists some prior work too. code's gone
This image (source) should show RULES on an sRGB-ish monitor and/or browser with a good color management.
and if it's resized with appropriate gamma should resize to:
However, libjpeg blends pixels in Cr/Cb color space, which has non-linear gamma, and chroma subsampling results in:
It could be better. I've prototyped a very slow and hacky chroma downsampling that generates:
so there's definitely a room for improvement.