Closed erikogabrielsson closed 7 months ago
I can't remember if there was a reason to disable MCT for lossless. Anyway, tests are passing here with MCT so it'll be enabled in the next version.
I'll also test if MCT can be enabled for > 3 components...
multi-component transform (MCT) must be set for the openjpeg encoder to do RGB to YBR conversion, which produces better compression.
It's not that easy. In my limited testing, lossless compression without MCT sometimes produced smaller images compared to with MCT. One synthetic image was a factor 3.2 smaller...
Fixed in the v2024.1.1 release.
Hi,
From my understanding, multi-component transform (MCT) must be set for the openjpeg encoder to do RGB to YBR conversion, which produces better compression. If the encoding is lossy, the irreversible color transform (ICT) is used, and if lossless the reversible color transform (RCT).
With imagecodecs, setting
mct=True
does not seem to produce YBR-converted compressed data when used together with lossless settings. I used theParse J2K codestream
code-snippet from this issue to parse out the MCT and DWT:When setting
level=80
andreversible=False
, MCT is applied:Comparing with Pillow (lossless):
and lossy:
I.e. Pillow will apply MCT for both lossless and lossy compression when
mct=1
is specified.Looking at the code, MCT is not set when quality != 0. Is there a reason for this? Am I missing something?