HDR -> SDR conversion

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
User avatar
admin
Site Admin
Posts: 4389
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin » Fri May 25, 2018 7:06 pm

Great to hear, douzi. Thanks for the update.

Narkyy
Posts: 51
Joined: Thu May 25, 2017 11:51 pm

Re: HDR -> SDR tonemapping

Post by Narkyy » Fri May 25, 2018 10:57 pm

I think light defaults for Gamma should be left like they are now, it all depends on the film tonemapped so it should be adjusted by the user.
Resized to 720p to take less space

default vs light=0.55
1.png
1.png (1.21 MiB) Viewed 1250 times
2.png
2.png (1.18 MiB) Viewed 1250 times
3.png
3.png (1.4 MiB) Viewed 1250 times
4.png
4.png (1.38 MiB) Viewed 1250 times

douzi
Posts: 6
Joined: Fri May 25, 2018 3:28 am

Re: HDR -> SDR tonemapping

Post by douzi » Sat May 26, 2018 5:15 pm

Hi,

I encountered some issue with highlights with DGHDRtoSDR.

Here's three-way comparison between DG(sw mode, hable) vs. MadVR (130nits, dumb mode, late gamut conversion) vs.VS Hable
The third one with Hable in vapoursynth is using the script here: https://forum.???.org/showthread.php? ... ost1832071

Same issue for "gamma" and "reinhard" too.

Image Image Image

Here's a link to the sample (screenshots at frame #400):
https://mega.nz/#!O0sEDTKZ!f-2a2cJEcKpx ... fTn4YMlPao

User avatar
admin
Site Admin
Posts: 4389
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin » Sat May 26, 2018 5:50 pm

"I encountered some issue with highlights with DGHDRtoSDR."

Can you please tell me what the issue is specifically? Refer to specific areas of specific frames and say what you think is wrong with them. I'm not good at guessing games. ;)

douzi
Posts: 6
Joined: Fri May 25, 2018 3:28 am

Re: HDR -> SDR tonemapping

Post by douzi » Sat May 26, 2018 5:57 pm

Sorry, forgot to point out its in the highlights, look at the lighting in the blue light bars, it looks very unnatural in your implementation while it is ok on source, MadVR and VS's hable tonemap.

The screenshots are taken from frame #400 in the sample clip.

User avatar
admin
Site Admin
Posts: 4389
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin » Sat May 26, 2018 6:05 pm

Thank you. Investigating...

User avatar
admin
Site Admin
Posts: 4389
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin » Tue May 29, 2018 2:27 pm

I hope everyone had a great Memorial Day.

The problem with douzi's stream is caused by my using a shortcut (for performance reasons) to avoid implementing the full EETF of ITU-R BT.2390. It works well for some streams but it's clear now that it does badly on some streams and I cannot avoid implementing the full EETF. It's going to take some time to implement.

As I mentioned, I'm learning a lot. ;)

User avatar
admin
Site Admin
Posts: 4389
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin » Fri Jun 01, 2018 9:13 pm

Status update: Hmm, well, implementing the EETF didn't make much difference and didn't fix douzi's stream! Digging deeper I found that it is the 2020->709 gamut mapping that is responsible. That is surprising to me as it is just the inverse of BT.2087 and is recommended in several papers I read. I'm going to dig way deeper into this but for now I will probably give you a version tomorrow that at least fixes douzi's stream. I have it working but don't expect it to be the final solution.

Still learning. ;)

User avatar
admin
Site Admin
Posts: 4389
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin » Sun Jun 03, 2018 11:48 am

Here is an interim fix for douzi's stream. A new gamut mapping option was added called gm. Read the user manual for details. This may not be the final solution as I am still researching gamut mapping methods. gm is a hand-rolled method that seems to perform reasonably.

This version may be ~5-10% faster when using gm="compress".

http://rationalqm.us/misc/DGHDRtoSDR_1.3.rar

Here is douzi's frame 400 with gm="compress":

douzi.bmp
douzi.bmp (1.1 MiB) Viewed 995 times

Narkyy
Posts: 51
Joined: Thu May 25, 2017 11:51 pm

Re: HDR -> SDR tonemapping

Post by Narkyy » Sun Jun 03, 2018 1:59 pm

I'm not sure if it's of any use (since there's not much documentation about the code), but there's this plugin which does conversion from BT2020 (and others) to BT709, as well as linear HDR -> SDR
https://github.com/jpsdr/HDRTools

I've been able to get good results (other than the linear lighting) with this script:
FFVideoSource("source.hevc", colorspace="YUV420P16")
ConvertYUVtoXYZ(Color=0,OutputMode=1, Gx=0.170,Gy=0.797,Bx=0.131,By=0.046,Rx=0.708,Ry=0.292,Wx=0.31271,Wy=0.32902) #BT2020 chromacity parameters
ConvertXYZ_HDRtoSDR(MinMastering=1, MaxMastering=1000,Coeff_X=20, Coeff_Y=20, Coeff_Z=20)
ConvertXYZtoYUV(Color=2, OutputMode=2, pColor=0)
z_ConvertFormat(pixel_type="YV12")
With example sample above: Image

Thanks for the update :hat:

Post Reply