mozilla / mozjpeg

Improved JPEG encoder.
Other
5.48k stars 415 forks source link

Use more precise chroma subsampling #8

Open kornelski opened 10 years ago

kornelski commented 10 years ago

There are few tricky problems in chroma subsampling: http://www.glennchan.info/articles/technical/chroma/chroma1.htm

e.g. libjpeg averages chroma of black pixels with chroma of neighboring color pixels, which causes darkened or desaturated edges. Even most naive blending with weighting by saturation gives a noticeable improvement:

https://github.com/pornel/jpeg-compressor#subsampling

dwbuiten commented 10 years ago

@pornel I'll maybe implement this soon. I looked at (the disabled) do_fancy_downsampling option, and it uses DCT scaling... which is crap. I'll look at something better which won't break ABI either.

kornelski commented 9 years ago

Possibly related: https://en.wikipedia.org/wiki/Helmholtz–Kohlrausch_effect

My idea: Saturation affects perceived lightness, so when pixels lose saturation due to chroma subsampling, it could be partially fixed by adjusting luma to compensate for the loss.

kornelski commented 8 years ago

Proposed technique tested using image in #193. It's not ideal, but better than nothing.

Nether Poppleton

njdoyle commented 8 years ago

Was this closed intentionally?

kornelski commented 8 years ago

edited Accidentally, but that's ok, my experimental code is not suitable for a PR.