PTGui 13 beta 4: Problems with JPG2000

79 views
Skip to first unread message

Nico Höllerich

unread,
Mar 17, 2024, 1:15:24 PMMar 17
to PTGui Support
TL;DR
  • Only use 4x and 1x (lossless) compression
  • Don't use color spaces besides sRGB
Background
I was very excited to directly output to a lossy image format with 16-bit depth. So I picked one of the recent panoramas (200 Megapixel; Details 1)
From a lossy JP2 file, I expect to preserve the full dynamic range at a reasonable file size (~ 150 MB). 

Analysis
So I exported it at 10x compression (120 MB) with sRGB color profile. Then, I increased exposure by 9EV to check for compression artifacts. The result is rather disappointing: 
2024-01-07-0041_jp2_sRGB_c10_+8EV.png
For comparison, this is the lossless compressed file (693 MB):
2024-01-07-0041_jp2_sRGB_lossless_+8EV.png

The compressed result is barely better than a 8-bit jpg (73.5 MB):
2024-01-07-0041_jpg_sRGB_q98_+8EV.png

Selecting the ProPhoto color space with 10x compression has the same issues:
2024-01-07-0041_jp2_ProPhoto_c10_+8EV.png

Workarounds
Go down to 4x compression (300 MB) to achieve just a slightly blurred result:
2024-01-07-0041_jp2_sRGB_c04_+8EV.png

Pick a custom color space with perceptual quantization (here: RGB_D65_202_Per_PeQ), then 10x compression is a bit better:
2024-01-07-0041_jp2_Rec20PeQ_c10_+8EV.png
However, ICC different from sRGB are not correctly interpreted by external applications (e.g. Gimp, XnView, IrfanView). See Details 4


Alternative lossy compression with no visual loss even at 200% crop:
  • EXR with DWAB (compression=30): 138 MB
  • JXL (Details 2): 65.2 MB
  • JP2 converted with vips and quality 65: 126 MB
It seems other codecs and encoders achieve a better result by allocating more accuracy to darker regions. Looking at the vips encoder, this should be achievable by the JP2 encoder with the correct settings (Details 3). 


---------
Details
  1. The panorama consists of 5 images, taken with the full frame fisheye AstrHori 12 mm on a Nikon Z7 II at f/8, 1/40, ISO64. Images are shot as RAW with 14-bit, lossless compression
  2. JXL: Encoding pipeline: TIFF -> PNM -> Jpeg XL using cjxl v0.10.2 with encoder settings d=0.4 e=6 target_intensity=8192
  3. JP2 encoder settings of vips: https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c
  4. Running exiftool 2024-01-07-0041_c10_Rec2020_PQ.jp2 gives:

Color Space                     : sRGB
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Description             : RGB_D65_202_Per_PeQ

It seems color space attributes are not correctly set.

Nico Höllerich

unread,
Mar 17, 2024, 1:18:54 PMMar 17
to PTGui Support
Folder with all output panoramas (encoding parameters are specified in filename): https://drive.google.com/drive/folders/1YhFgcMCLuKE_MZMhKxUc867be5QzM5LX?usp=sharing

PTGui Support

unread,
Mar 19, 2024, 11:45:05 AMMar 19
to pt...@googlegroups.com
Hi Nico,

Thanks for the thorough testing, this is very helpful! Looks like the
encoder settings can be improved to get results similar to VIPS.

And it seems JpegXL is the way to go in the longer term.

Kind regards,

Joost Nieuwenhuijse
www.ptgui.com

On 17-03-2024 17:51, Nico Höllerich wrote:
> *TL;DR*
>
> * Only use 4x and 1x (lossless) compression
> * Don't use color spaces besides sRGB
>
> *Background*
> I was very excited to directly output to a lossy image format with
> 16-bit depth. So I picked one of the recent panoramas (200 Megapixel;
> Details 1)
> From a lossy JP2 file, I expect to preserve the full dynamic range at a
> reasonable file size (~ 150 MB).
>
> *Analysis*
> So I exported it at *10x compression* (120 MB) with sRGB color profile.
> Then, I increased exposure by 9EV to check for compression artifacts.
> The result is rather disappointing:
> 2024-01-07-0041_jp2_sRGB_c10_+8EV.png
> For comparison, this is the *lossless *compressed file (693 MB):
> 2024-01-07-0041_jp2_sRGB_lossless_+8EV.png
>
> The compressed result is barely better than a *8-bit jpg* (73.5 MB):
> 2024-01-07-0041_jpg_sRGB_q98_+8EV.png
>
> Selecting the *ProPhoto color space with 10x* compression has the same
> issues:
> 2024-01-07-0041_jp2_ProPhoto_c10_+8EV.png
>
> *Workarounds*
> Go down *to 4x compression* (300 MB) to achieve just a slightly blurred
> result:
> 2024-01-07-0041_jp2_sRGB_c04_+8EV.png
>
> Pick a custom color space with perceptual quantization (here:
> *RGB_D65_202_Per_PeQ*), then *10x compression* is a bit better:
> 2024-01-07-0041_jp2_Rec20PeQ_c10_+8EV.png
> However, ICC different from sRGB are not correctly interpreted by
> external applications (e.g. Gimp, XnView, IrfanView). See Details 4
>
>
> Alternative lossy compression with no visual loss even at 200% crop:
>
> * EXR with DWAB (compression=30): 138 MB
> * JXL (Details 2): 65.2 MB
> * JP2 converted with vips
> <https://github.com/libvips/libvips/releases> and quality 65: 126 MB
>
> It seems other codecs and encoders achieve a better result by allocating
> more accuracy to darker regions. Looking at the vips encoder, this
> should be achievable by the JP2 encoder with the correct settings
> (Details 3).
>
>
> ---------
> *Details*
>
> 1. The panorama consists of 5 images, taken with the full frame fisheye
> AstrHori 12 mm on a Nikon Z7 II at f/8, 1/40, ISO64. Images are shot
> as RAW with 14-bit, lossless compression
> 2. JXL: Encoding pipeline: TIFF -> PNM -> Jpeg XL
> <https://jpegxl.info/>using cjxl
> <https://github.com/libjxl/libjxl/releases>v0.10.2 with encoder
> settings d=0.4 e=6 target_intensity=8192
> 3. JP2 encoder settings of
> vips: https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c
> 4.
> Running exiftool 2024-01-07-0041_c10_Rec2020_PQ.jp2 gives:
>
>
> Color Space                     : sRGB
> Color Space Data                : RGB
> Profile Connection Space        : XYZ
> Profile Description             : RGB_D65_202_Per_PeQ
>
> It seems color space attributes are not correctly set.
>
> --
> You received this message because you are subscribed to the Google
> Groups "PTGui Support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ptgui+un...@googlegroups.com
> <mailto:ptgui+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Nico Höllerich

unread,
Mar 19, 2024, 7:37:03 PMMar 19
to PTGui Support

Yes, I hope that JXL will become the ubiquitous successor of jpg. I already saved some of my panoramas in this format and hope PTGui will support it natively in the future.

 

Some insights from experimenting with the format:

  • The format supports two encoding paths: VarDCT (comparable to jpeg) for low dynamic images and modular (wavelets + other compression mechanisms) for high dynamic images with values > 1. VarDCT is always lossy. Modular is designed for lossless compression but can be used for lossy, too.
  • Lossy modular is a great alternative for OpenEXR since it allows lossy encoding of floats: There is no need to finetune the compression parameter to achieve the desired quality in shadows
  • Setting intensity_target is essential if libjxl assumes a wrong dynamic range (e.g. with sRGB colour profiles, shadows below -8EV are cut off). I usually use 8192 for images with the dynamic range of a single 14-bit camera raw and a maximum of 65000 for exposure stacks.
  • The streaming encoder allows efficient processing of gigapixel panoramas (unfortunately, the reference compression software only allows 16-bit pnm files for streaming input).
  • The developers are very responsive and supportive when new applications adopt the format.

PTGui Support

unread,
Mar 20, 2024, 7:22:13 AMMar 20
to pt...@googlegroups.com
That's helpful, thanks!

Kind regards,

Joost Nieuwenhuijse
www.ptgui.com

On 20-03-2024 00:37, Nico Höllerich wrote:
> Yes, I hope that JXL will become the ubiquitous successor of jpg. I
> already saved some of my panoramas in this format and hope PTGui will
> support it natively in the future.
>
> Some insights from experimenting with the format:
>
> * The format supports two encoding paths: VarDCT (comparable to jpeg)
> for low dynamic images and modular (wavelets + other compression
> mechanisms) for high dynamic images with values > 1. VarDCT is
> always lossy. Modular is designed for lossless compression but can
> be used for lossy, too.
> * Lossy modular is a great alternative for OpenEXR since it allows
> lossy encoding of floats: There is no need to finetune the
> compression parameter to achieve the desired quality in shadows
> * Setting intensity_target is essential if libjxl assumes a wrong
> dynamic range (e.g. with sRGB colour profiles, shadows below -8EV
> are cut off). I usually use 8192 for images with the dynamic range
> of a single 14-bit camera raw and a maximum of 65000 for exposure
> stacks.
> * The streaming encoder allows efficient processing of gigapixel
> panoramas (unfortunately, the reference compression software only
> allows 16-bit pnm files for streaming input).
> * The developers are very responsive and supportive when new
> applications adopt the format.
>
> PTGui Support schrieb am Dienstag, 19. März 2024 um 16:45:05 UTC+1:
>
> Hi Nico,
>
> Thanks for the thorough testing, this is very helpful! Looks like the
> encoder settings can be improved to get results similar to VIPS.
>
> And it seems JpegXL is the way to go in the longer term.
>
> Kind regards,
>
> Joost Nieuwenhuijse
> www.ptgui.com <http://www.ptgui.com>
> > <https://jpegxl.info/ <https://jpegxl.info/>>using cjxl
> > <https://github.com/libjxl/libjxl/releases
> <https://github.com/libjxl/libjxl/releases>>v0.10.2 with encoder
> > settings d=0.4 e=6 target_intensity=8192
> > 3. JP2 encoder settings of
> > vips:
> https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c <https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c>
> > 4.
> > Running exiftool 2024-01-07-0041_c10_Rec2020_PQ.jp2 gives:
> >
> >
> > Color Space                     : sRGB
> > Color Space Data                : RGB
> > Profile Connection Space        : XYZ
> > Profile Description             : RGB_D65_202_Per_PeQ
> >
> > It seems color space attributes are not correctly set.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "PTGui Support" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to ptgui+un...@googlegroups.com
> > <mailto:ptgui+un...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com> <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "PTGui Support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ptgui+un...@googlegroups.com
> <mailto:ptgui+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ptgui/5cc12999-8e08-4b27-9ac1-4ffd376a06ccn%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/5cc12999-8e08-4b27-9ac1-4ffd376a06ccn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Nico Höllerich

unread,
Jul 24, 2024, 2:22:09 PM (3 days ago) Jul 24
to PTGui Support
I rerun the test with Beta 8 and results are satisfying. Quality 65 perserves schadows in a visually lossless way - both in vips and PTGui. File sizes are about the same, too. 

The encoder improvement of jp2000 was worth the effort - I can recommend the file format now. 

PTGui Support

unread,
Jul 25, 2024, 1:59:36 PM (2 days ago) Jul 25
to pt...@googlegroups.com
Great! Thanks for confirming.

Kind regards,

Joost Nieuwenhuijse
www.ptgui.com

On 24-07-2024 20:22, Nico Höllerich wrote:
> I rerun the test with Beta 8 and results are satisfying. Quality 65
> perserves schadows in a visually lossless way - both in vips and PTGui.
> File sizes are about the same, too.
>
> *The encoder improvement of jp2000 was worth the effort - I can
> recommend the file format now. *
>
> PTGui Support schrieb am Mittwoch, 20. März 2024 um 12:22:13 UTC+1:
>
> That's helpful, thanks!
>
> Kind regards,
>
> Joost Nieuwenhuijse
> www.ptgui.com <http://www.ptgui.com>
> > www.ptgui.com <http://www.ptgui.com> <http://www.ptgui.com
> https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c <https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c> <https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c <https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c>>
> > > 4.
> > > Running exiftool 2024-01-07-0041_c10_Rec2020_PQ.jp2 gives:
> > >
> > >
> > > Color Space                     : sRGB
> > > Color Space Data                : RGB
> > > Profile Connection Space        : XYZ
> > > Profile Description             : RGB_D65_202_Per_PeQ
> > >
> > > It seems color space attributes are not correctly set.
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "PTGui Support" group.
> > > To unsubscribe from this group and stop receiving emails from it,
> > send
> > > an email to ptgui+un...@googlegroups.com
> > > <mailto:ptgui+un...@googlegroups.com>.
> > > To view this discussion on the web visit
> > >
> >
> https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com> <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com>> <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ptgui/a7287b4b-e807-407e-8cae-4e087116c91fn%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "PTGui Support" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to ptgui+un...@googlegroups.com
> > <mailto:ptgui+un...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ptgui/5cc12999-8e08-4b27-9ac1-4ffd376a06ccn%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/5cc12999-8e08-4b27-9ac1-4ffd376a06ccn%40googlegroups.com> <https://groups.google.com/d/msgid/ptgui/5cc12999-8e08-4b27-9ac1-4ffd376a06ccn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ptgui/5cc12999-8e08-4b27-9ac1-4ffd376a06ccn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "PTGui Support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ptgui+un...@googlegroups.com
> <mailto:ptgui+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ptgui/4180d04b-97ef-47a9-a2ca-fdbaffb4cbe0n%40googlegroups.com <https://groups.google.com/d/msgid/ptgui/4180d04b-97ef-47a9-a2ca-fdbaffb4cbe0n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages