assign hdr metadata and display hdr images

Feel free to comb through the JPEG XR spec and let us know where and how the colour space information is supposed to be encoded.

Being proprietary software, there’s no way to know what Microsoft’s image viewers support and implement for each format. (And seeing that they are pushing JPEG XR, they could be treating in a special way.)

As for the (linear) sRGB assumption, @Entropy512 just explained why it is a valid one for floating point EXRs and JXRs. Just to back this up, in the absence of explicit colour primaries, OpenEXR indeed assumes sRGB/Rec709 ones by default: https://github.com/AcademySoftwareFoundation/openexr/blob/6258740337bf3859ed8abcf8d99a1671b2cdd06d/src/lib/OpenEXR/ImfChromaticities.h#L36-L50

2 Likes

This is where you went wrong. You say it’s nonfunctional - so why did you use it?

Per that link:
“Almost all pixel formats supported by JPEG XR can be loaded. Incompatible formats, however, will first be converted to a representation that GIMP understands (this means you’ll loose HDR data, for example). All RGB pixel formats are converted to 24bpp RGB, all RGBA formats to 32bpp BGRA, and all grayscale formats to 8bpp Gray. Black-white images are imported as indexed images.”

Note that it didn’t say you lost HDR metadata - it says (as is expected when trying to cram float16 into an int8) that you will lose data

If you really want to create a Rec. 2100 encoded 10bpp image from a JXR, you can start with the Python tool I linked, but it’ll need quite a bit of work since doing that was unnecessary for the original purposes of that script - it was designed to generate TIFFs that could be ingested into RawTherapee, so it doesn’t alter the data at all and tags it as linear with sRGB primaries, which matches every JXR file I’ve ever seen. You will need to:

  • Calculate the appropriate matrix for converting an image encoded with sRGB primaries to Rec.2020 primaries, I’d suggest https://www.colour-science.org/ for that
  • Apply that matrix to the float32 numpy array representing your image data after the script loaded an image
  • At this point you should not have any negative numbers - if you do, you probably made a math error because it’s extremely unlikely (but possible) that the image contains colors outside of the Rec. 2020 colorspace. (negative float16/float32 numbers are a signal of either a bug or out-of-gamut colors)
  • Take your image data that is now floating point linear with rec. 2020 primaries, and apply the HLG or PQ transfer functions
  • Export as HEIC/HEIF with appropriate metadata - I can’t help you here. Or export as int16 linear Rec2020 TIFF then feed that to ffmpeg to create a video clip, see Experimenting with HLG and HDR10 for still images - #22 by Entropy512 for an example
2 Likes

@xpatUSA, no issue thank for answering as well !
@kmilos, thank for the link !

@Entropy512, thank for this excellent and very informative answer !

copy, about the details involvintg the floating point encoding, the relation between the the standard and the creation of the format, right.

ok copy ! so it s linear with negative numbers ! that explains everything !

This is where you went wrong. You say it’s nonfunctional - so why did you use it?

tried it at the begining of these investigations and now that you explain why you loose the metadat based on the description, it a lot clearer.

but it’ll need quite a bit of work since doing that was unnecessary

then do you know a usable format that supports it natively ?

so you are saying that the tiff are holding the out of range data in negative numbers bu the viewer does not find it as it finds it in [.jxr, .exr, .hdr] ?
is there a way to display .tif in hdr like the obs.jxr ?
what would you use to display and create .hdr images ?

so does it means that if you fill an image in blue max value, you export it as .exr, .hdr, will this image once displayed in microsoft photos, hdr + wcg image viewer be in hdr ? will the value coded to 255 blue will be the max value that the display can output in hdr ?

do you know editing software that reoorts hdr in the swachain besides affinity photo ?
do you know other softwares than windows photos, hdr + wcg image viewer that displays [.jxr, .exr, .hdr] in hdr ?

No. Again, this is proprietary software, we can’t know what it does. If it supports floating point JPEG XR in some special way, it does not mean it will support floating point EXR and TIFF the same way.

1 Like

no. again, not talking about .jxr here, talking about [.exr, .hdr], if you fill it with full blue, will the color be at max luminance value ?
because tried it appears like it but is it really the case digiatlly ?
.jxr and windows photos are proprietary, but hdr + wcg image viewer is not so if you want to only use non proprietary software, do you know other hdr image viewer by the way ?

Hi,
Since this now seems to be not darktable-specific anymore, from my limited investigations, I found out that:

  • Google Chrome on Mac os should be able to display avif HDR images (with rec.2100 PQ at least)

  • maybe this works on windows too? I don’t know because I don’t use windows, but there’s a chance it might if you configure HDR output properly (which I don’t know how to do)

  • chrome on Linux will at least tonemap the HDR avif to sdr, so that it looks reasonable on a standard sdr display

  • on my TV, I can successfully trigger hdr output when using heif with either hlg or pq encoding (still rec.2100)

  • for both avif and heif, you need to tag the files properly. that means no ICC profiles, and use of the nclx box instead to specify the primaries and transfer function

HTH

1 Like

Try:

@agriggio and @kofa thank for the detailled suggestions !
definitely giving it a try !

There’s also

I have no experience with any of these, as I don’t do HDR.

There’s this thread, and the first comment references another:

Nice. On mine, I cannot - At least until 2-3 years ago, the only reliable content distribution format for HDR stills was to encode it to an HLG or PQ + Rec. 2020 10-bit H.265 video. (I linked to how I did that in one of my other posts)

At least in theory it might now be possible to create an HDR image viewer that works in full screen with gamescope on Linux (right now the only userspace that has HDR support…), but that’s extremely niche.

In general, HDR stills are a sh*tshow as far as support and compatibility. Float JXR works well in Windows, but on any other OS your best bet is to convert it to float TIF - and even then, that’s really only valid for feeding it to darktable, ART, or RT to tonemap it down to SDR, there are no HDR image viewers. MacOS seems to have the best support for HDR stills in the more well known/standardized formats (AVIF, HEIF/HEIC, etc)

@agriggio, the [.jxr, .exr, .hdr] images does not display at all with chrome on windows when you contextual menu\open with chrome.

@kofa, thank for the suggestion,

tried it, an the darktable_srgb.exr in the onedrive link which displays perfectly in hdr with hdr + wcg image viewer, displays with overexposed highlights and washed out colors with ‘hdrview’ and ‘tev’.

@agriggio. @Entropy512,

on my TV, I can successfully trigger hdr output when using heif with either hlg or pq encoding (still rec.2100)

Nice. On mine, I cannot

why not using the more reliable manual hdr enabling process ?
simillar to how it works on windows and on samsung tv :
_tv settings\‘uhd color hdmi’ : on
_windows settings\display\hdr switch : on
_nvidia control panel\change resolution\output color depth : 12 bpc.

@Entropy512

In general, HDR stills are a sh*tshow as far as support and compatibility. Float JXR works well in Windows, but on any other OS your best bet is to convert it to float TIF - and even then, that’s really only valid for feeding it to darktable, ART, or RT to tonemap it down to SDR, there are no HDR image viewers.

do you know any other hdr display software
besides :
editor :
_affinity photo (opens [.jxr, ,exr, .hdr] in hdr on hdr displays perfectly, edit in hdr on hdr displays, exports in hdr in [exr, .hdr, avif])
viewers :
_microsoft photo [opens .jxr in hdr on hdr displays perfectly]
_hdr + wcg image viewer [opens [.jxr, ,exr, .hdr] in hdr on hdr displays perfectly]
?

MacOS seems to have the best support for HDR stills in the more well known/standardized formats (AVIF, HEIF/HEIC, etc)

well standardized ? where ? do you know a viewer able to display .avif in hdr on hdr displays ?

Try avif.

I don’t know what you are talking about, sorry.

Try avif.

already tried with chrome, edge, opera gx : the image does not load at all.
besides this do you know any hdr viewer exist allowing to display avif in hdr ?

why not using the more reliable manual hdr enabling process ?

I don’t know what you are talking about, sorry.

you are apparently waiting for hdr to automatically switch on or something :
hdr does not automatically switch on, you have to switch hdr on manually following this procedure and it s more reliable than waiting for it to potentially switch on automatically :
doing it since 2018 when hdr became available on windows and never had any issue when displaying hdr content on windows.
here s the procedure :

_tv settings\‘uhd color hdmi’ : on (don t need to do it each time, leave it on it s to enable the greater input bandwith for 4k, rgb, full, 12 bpc, 30 hz max for hdmi. 2.0 or, 120 hz max for hdmi 2.1 )
_windows settings\display\hdr switch : on
_nvidia control panel\change resolution\output color depth : 12 bpc.

@Entropy512
can you explain why on this image when you take it in affinity photo or krita and you take one of the highest luminance bright with the color picker, you replicate the color with 2 brush lines, and the lines are not white but they are black, like to show that the color are out range or something ?
is it related to the negative values management you talked about earlier ?
do you know how to recreate these colors at these luminances in affinity, krita or, any other software ?

solved

strange how all the primaries supports 60 value but the pure blue can only go to 2 before it clips to purple with more than that.
do you know why ?

Videos are not ICC color managed, so most program you mention will consider stills extracted from videos, as regular sRGB image. If they are actually encoded in anything else, they won’t look ok.

That imply you need to know the exact encoding applied to the video, and then you need to reverse that, to say to linear Rec2020 or better yet, CIEXYZ and then assign or convert (if XYZ) to the ICC profile you want. Then, on any ICC color managed system and software, you should see the exact same image.

I’m not sure, you’ll be able to find the exact encoding that was applied to the video, but if it’s there in the metadata of the video, you’re in luck.

thank for answering !

so for instance, how and what would you use to extract frames from a video encoded in [encoder : hevc, format : yuv420p10, level : limited, colorimatrix : bt.202-ncl, primaries : bt.2020, transfert : pq] ?
would you use ffmpeg (tried the frames extract function : does not keep the hdr data in the [.exr, .hdr, .avif] for insatance) ?
would you use image magick ?
what process would you apply to the individual ouputted still images afterwards ?

From what I understand, in video, the various transforms are baked into the data that is used to create the images on the display. Even if you know the exact transforms, I’m not convinced all of them are invertible. Maybe a screen capture, for which you know and/or have the ICC profile, then, you can assign this display profile, and it should look the same on any display after that. I don’t think most program will give you the equivalent of a screen capture though.

If I use a recent version of FFmpeg to export frames from an HLG video to PNG images, then test with a recent version of MediaInfo, I can see a CICP chunk with the correct metadata for colour primaries, video range and transfer function. (Colour matrix isn’t needed as PNG are RGB only so there is no YCbCr or ICtCp conversion)

Pretty sure it will do the same for PQ, although haven’t tested.

Caveat - the original video needs to be correctly flagged or have the flags set on the command line.