AcademySoftwareFoundation / OpenImageIO

Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications.
https://openimageio.readthedocs.org
Apache License 2.0
1.95k stars 585 forks source link

[BUG] oiiotool jpeg output as Output-sRGB has dark halos around highlights #4035

Closed p0las closed 11 months ago

p0las commented 11 months ago

Describe the bug A simple conversion of an EXR from aces_cg to output sRGB when saved as JPG has dark halos around highlights. saving as PNG or any other format looks correct. Tried all sorts of filters and settings and I'm unable to fix it.

oiio-jpg_comp_main_v0001_contactsheet 0001

To Reproduce Steps to reproduce the behavior: convert the attached EXR using this command:

oiiotool -i "attached_exr" --colorconvert "ACES - ACEScg" "Output - sRGB" --compression jpeg:99 -o "srgb-output.jpg"

oiiotool -i "attached_exr" --colorconvert "ACES - ACEScg" "Output - sRGB" --compression jpeg:99 -o "srgb-output.png"

oiio-jpg_comp_main_v0001.0001.exr.zip

Expected behavior both files should look exactly the same (minus compression artefacts). the jpg however has clear dark halo around the bright shape in the middle.

Platform information:

Filters available: box, triangle, gaussian, sharp-gaussian, catmull-rom, blackman-harris, sinc, lanczos3, radial-lanczos3, nuke-lanczos6, mitchell, bspline, disk, cubic, keys, simon, rifman Dependent libraries: FFMpeg 4.4 (Lavf58.76.100), libheif 1.12.0, jpeg-turbo 2.0.6/jp62, null 1.0, OpenEXR 2.5.0, libpng 1.6.37, LIBTIFF Version 4.3.0 OIIO 2.4.0dev built for C++14/199711 sse2 Running on 12 cores 63.7GB sse2,sse3,ssse3,sse41,sse42,avx,avx2,avx512f,avx512dq,avx512cd,avx512bw,avx512vl,fma,f16c,popcnt,rdrand

EDIT: tested with the latest and the problem is still there: OpenColorIO 2.1.2 Filters available: box, triangle, gaussian, sharp-gaussian, catmull-rom, blackman-harris, sinc, lanczos3, radial-lanczos3, nuke-lanczos6, mitchell, bspline, disk, cubic, keys, simon, rifman Dependent libraries: OpenEXR 3.1.5, LIBTIFF Version 4.4.0, jpeg-turbo 2.1.4/jp62, FFMpeg 4.4 (Lavf58.76.100), libheif 1.13.0, null 1.0, libpng 1.6.38 OIIO 2.6.0.0dev built for C++14/199711 sse2 Running on 12 cores 63.7GB sse2,sse3,ssse3,sse41,sse42,avx,avx2,avx512f,avx512dq,avx512cd,avx512bw,avx512vl,fma,f16c,popcnt,rdrand

lgritz commented 11 months ago

You're seeing artifacts of the JPEG chroma subsampling, which OIIO by default sets to 4:2:2. In addition to the --compression, please also add this:

--attrib jpeg:subsampling 4:4:4
lgritz commented 11 months ago

JPEG as a format and compression technique was designed for photographic images. It actually behaves very poorly for images with areas of solid color and hard edges. At the very least, all of the default settings that are great choices for photos are all wrong for that kind of image. It's just not the kind of image that JPEG compression was designed to handle well.

p0las commented 11 months ago

@lgritz thank you. I was suspecting chroma but wasn't sure if there was a way to control it. This indeed fixed the issue. Thank you mate. Appreciate. I know that jpg is not designed for solid colours etc. I made this simple example to demonstrate the issue as I cannot use production frames.