Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
25th January 2018, 17:25 | #41 | Link |
Registered User
Join Date: Oct 2015
Posts: 54
|
I've taken the formula for decomposing rgb to luma and come back(it gives different result from a classic rgb->yuv->rgb and it is faster) from here:https://www.google.it/amp/s/imdoingi...-blacks-3/amp/
The jhon hable tonemapping from here:http://filmicworlds.com/blog/filmic-...ing-operators/ |
25th January 2018, 19:36 | #42 | Link |
Registered User
Join Date: Oct 2002
Location: France
Posts: 2,316
|
... I'm still unable to see the whole mathematical formula path .
I also don't see any formula with exposed_bias in your links... I have no idea what is the mathematical results of such things Code:
tm = core.std.Expr(c, expr="x {exposure_bias} * 0.15 x {exposure_bias} * * 0.05 + * 0.004 + x {exposure_bias} * 0.15 x {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)#12=1200 nits / 100 nits w = core.std.Expr(c, expr="{exposure_bias} 0.15 {exposure_bias} * 0.05 + * 0.004 + {exposure_bias} 0.15 {exposure_bias} * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)# c = core.std.Expr(clips=[tm,w], expr=" x 1 y / * ",format=vs.RGBS) I mean... Your script result in several mathematic formulas apllied step by step. Is it possible to have the formula of each step ? Last edited by jpsdr; 25th January 2018 at 19:42. |
25th January 2018, 21:56 | #43 | Link | |
Registered User
Join Date: Dec 2009
Posts: 72
|
Quote:
https://github.com/ifb/vapoursynth-t.../tonemap.c#L44 |
|
27th January 2018, 10:40 | #45 | Link |
Registered User
Join Date: Oct 2002
Location: France
Posts: 2,316
|
I've tried to read again the BT.2100 and BT.2390.
I'm still confused. I'm unable to relate the formulas of OETF, EOTF, OOTF functions with the formulas of the tonemap functions you've all provided in your links. Where from the BT.2100 and BT.2390 did you get the formulas of the tonemap functions (what page, chapter ) ? I'm still unable to figure out where the "white max" information is involved in the OETF, EOTF, OOTF functions... |
27th January 2018, 19:40 | #46 | Link |
Registered User
Join Date: Oct 2015
Posts: 54
|
EOTF and tonemapping are two different things, you could read about the st2084 formula in the official documentation or in the zimg code or elsewhere.
I've founded an interesting pdf about hdr and tonemapping http://www.eusipco2016.org/documents...R_tutorial.pdf at page 119 the EOTF formula. At pages 100-107 some methods for the correction of the saturation. From the first one I've done a vapoursynth function with only two parameters,(clip and source_peak)it's simple but at my eyes is better then my previous attempt https://filebin.net/7c6kocrmxxnat1cp Code:
import vapoursynth as vs import tmsimple core = vs.get_core() c = core.ffms2.Source(source = 'C:/.../testhdr.mkv') c=core.resize.Bicubic(clip=c, format=vs.RGBS,filter_param_a=0.0,filter_param_b=0.75, range_in_s="limited", matrix_in_s="2020ncl", primaries_in_s="2020", primaries_s="2020", transfer_in_s="st2084", transfer_s="linear",dither_type="none", nominal_luminance=1000) c=tmsimple.tm(clip=c,source_peak=1000) c=core.resize.Bicubic(clip=c, format=vs.YUV420P8, filter_param_a=0.0, filter_param_b=0.75, matrix_s="709", primaries_in_s="2020", primaries_s="709", transfer_in_s="linear", transfer_s="709",dither_type="ordered") c.set_output() |
14th April 2018, 22:59 | #48 | Link |
Registered User
Join Date: May 2014
Posts: 33
|
There is now a tone-mapping plug-in for avisynth+: http://rationalqm.us/DGTonemap.rar
It supports both Hable and Reinhard methods. Last edited by jkilez; 14th April 2018 at 23:01. |
16th April 2018, 20:32 | #49 | Link |
Registered User
Join Date: Aug 2012
Posts: 203
|
Some times ago i wrote a c++ implementation of the hable implementation in tmap, i don't remeber how much faster it is, but IIRC about 2x .
It only works for float input with mod8 resolution video and AVX CPU, i didn't bother writing an SSE implementation due to the high amount of FMAD instruction used. The static buffer optimization only work on windows right now. If i see any interest in this i'll try to add some functionality like the debug views, non mod8 support, etc Here the repo https://github.com/MonoS/tmap-vapoursynth/tree/V1 |
2nd January 2019, 06:31 | #50 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Japanese television recently launched their 4k/8k broadcasting last month, here's a same frame comparison between a 1080p HD version and the 4k HDR version:
1080p: 4K HDR: note: delete the last letter ("h") on the image name to get the original size. None of the three methods in the tonemap plugin I've tested can map the 4k one to look like 1080 one. They all failed on the color mapping. |
2nd January 2019, 08:58 | #52 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Here's the sample clip, there's no metadata with the stream.
script I've tested: Code:
rgb_clip = core.resize.Bicubic(clip, height=1080, width=1920, matrix_in_s="709", format=vs.RGBS) # hable tonemap_clip = core.tonemap.Hable(rgb_clip, exposure=7.0, a=0.10, b=0.50, c=0.10, d=0.20, e=0.01, f=0.08, w=5.2) # mobius tonemap_clip = core.tonemap.Mobius(rgb_clip, exposure=1.5, transition=0.9, peak=1.0) #reinhard tonemap_clip = core.tonemap.Reinhard(rgb_clip, exposure=1.5, contrast=0.5, peak=1.0) |
7th January 2019, 20:19 | #53 | Link | |
Registered User
Join Date: Dec 2009
Posts: 72
|
Quote:
<edit> I'm pretty sure it's HLG but with Rec.709 color, which is weird but I suppose they are worried about backward compatibility. This is with zero tweaking, just copied from the tonemap examples: Code:
c = core.ffms2.Source(source = "4kbs_trim.mp4") c = core.resize.Lanczos(clip=c, format=vs.RGBS, width=1920, height=1080, matrix_in_s="709", transfer_in_s="std-b67", transfer_s="linear", nominal_luminance=1000) c = core.tonemap.Mobius(clip=c, exposure=4) c = core.resize.Lanczos(clip=c, format=vs.YUV420P10, matrix_s="709", primaries_in_s="709", primaries_s="709", transfer_in_s="linear", transfer_s="709") Last edited by ifb; 7th January 2019 at 20:51. |
|
8th January 2019, 03:44 | #54 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
^ this If the goal was to "match" the other version, I'd probably just use normal color manipulation filters . |
|
8th January 2019, 17:59 | #55 | Link |
Registered User
Join Date: Oct 2015
Posts: 54
|
Hi :-)
I would like to use normal color manipulation filters too for this video. I've made a.cube file for the sdr match. https://filebin.net/uu8l2zh4xso2gqd2 Code:
import vapoursynth as vs core = vs.get_core() c = core.lsmas.LibavSMASHSource(source= "C:/Users/..../4kbs_trim.mp4") c=core.resize.Bicubic(clip=c, format=vs.RGB48, chromaloc_in_s="left", chromaloc_s="center", filter_param_a=0.0, filter_param_b=0.75, matrix_in_s="2020ncl", range_in_s="limited",dither_type="none") c=core.timecube.Cube(c, cube="C:/..../Videos/4kbshdr.cube") c=core.resize.Bicubic(clip=c, format=vs.YUV420P8, chromaloc_in_s="center", chromaloc_s="left",matrix_s="709", filter_param_a=0.0, filter_param_b=0.75, range_in_s="full", range_s="limited",dither_type="none") c.set_output() Last edited by age; 8th January 2019 at 19:02. |
8th January 2019, 21:05 | #56 | Link |
Registered User
Join Date: Dec 2009
Posts: 72
|
HLG has a different look ("natural" to use BBC/BT.2408 terminology) versus the "traditional" look of SDR. To convert, you need to do a scene-referred conversion, which is not exposed in z.lib/vapoursynth. You can patch z.lib and build your own custom vapoursynth.dll, but really you're just better off using a LUT like shown.
The BBC has some official .cube files they provide for doing this sort of thing. |
8th January 2019, 22:11 | #57 | Link |
Registered User
Join Date: Oct 2015
Posts: 54
|
That video doesn't look hdr, but more like an hdr video converted to rec709 without tonemapping
for example with hable tonemapping for 1000 nits Code:
import vapoursynth as vs core = vs.get_core() c = core.lsmas.LibavSMASHSource(source= "C:/Users//Desktop/4kbs_trim.mp4") c=core.resize.Bicubic(clip=c, format=vs.RGBS,filter_param_a=0.0,filter_param_b=0.75, range_in_s="limited", matrix_in_s="2020ncl", chromaloc_in_s="left", chromaloc_s="center", transfer_in_s="709", transfer_s="linear",dither_type="none") #insert here tonemapping 1000nits #exposure_bias=10 #tm = core.std.Expr(c, expr="x {exposure_bias} * 0.15 x {exposure_bias} * * 0.05 + * 0.004 + x {exposure_bias} * 0.15 x {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias)) #w=((exposure_bias*(0.15*exposure_bias+0.10*0.50)+0.20*0.02)/(exposure_bias*(0.15*exposure_bias+0.50)+0.20*0.30))-0.02/0.30 #tm = core.std.Expr(clips=[tm,c], expr="x 1 {w} / * ".format(exposure_bias=exposure_bias,w=w)) c=core.resize.Bicubic(clip=c, format=vs.RGBS, transfer_in_s="linear", transfer_s="709",dither_type="none") c=core.resize.Bicubic(clip=c, format=vs.YUV420P8, chromaloc_in_s="center", chromaloc_s="left", filter_param_a=0.0, filter_param_b=0.75, range_in_s="full", range_s="limited", matrix_s="709",dither_type="none") c.set_output() |
10th January 2019, 19:08 | #59 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Ok after reading the hable reference article from ifb's tonemap page, I just realized that hable is not for 4k hdr tv to sdr conversion. It was created for images and SDR games to make them looks HDR. So this whole approach to use it for "4K HDR TV content -> SDR" is just wrong. The right tool for this in vapoursynth is DGHDRtoSDR.
|
10th January 2019, 19:20 | #60 | Link | |
Registered User
Join Date: May 2005
Posts: 1,462
|
Quote:
Which also makes me wonder, would there be a way for DGHDRtoSDR to extract values like 'Max luminance: 1000' from the metadata itself?
__________________
Gorgeous, delicious, deculture! |
|
Tags |
hdr, sdr |
Thread Tools | Search this Thread |
Display Modes | |
|
|