Anime addict
Join Date: Feb 2009
Location: Spain
Posts: 673
|
For how want, I have completed the function (thanks to _Are):
Code:
import vapoursynth as vs
def scale(old_value, new_bd=16):
return int((old_value * ((1 << new_bd) - 1)) / 255)
def brightdfttestmod(clip, sbright=0, smedium=0, sdark=0, th_low=20, th_med=40, th_high=100, tbsize=5,
sbsize=18, sosize=9, planes=[0,1,2], luma=True):
core = vs.get_core()
if not isinstance(clip, vs.VideoNode):
raise ValueError('This is not a clip')
# This scales the values for Levels in case we are not working with 8-bit clips
if clip.format.bits_per_sample != 8:
th_low = scale(th_low, clip.format.bits_per_sample)
th_med = scale(th_med, clip.format.bits_per_sample)
th_high = scale(th_high, clip.format.bits_per_sample)
# Bright
if sbright > 0:
bright = core.dfttest.DFTTest(clip, sigma=sbright, tbsize=tbsize, sbsize=sbsize, sosize=sosize, planes=planes)
else:
bright = clip
# Medium
if smedium > 0:
medium = core.dfttest.DFTTest(clip, sigma=smedium, tbsize=tbsize, sbsize=sbsize, sosize=sosize, planes=planes)
else:
medium = clip
# Dark
if sdark > 0:
dark = core.dfttest.DFTTest(clip, sigma=sdark, tbsize=tbsize, sbsize=sbsize, sosize=sosize, planes=planes)
else:
dark = clip
if luma==True:
luma_layer= core.std.ShufflePlanes(medium, planes=[0], colorfamily=vs.GRAY)
mmask = core.std.Levels(luma_layer, th_med, th_high, 1.0, (1 << clip.format.bits_per_sample) - 1, 0)
dmask = core.std.Levels(luma_layer, th_low, th_med, 1.0, (1 << clip.format.bits_per_sample) - 1, 0)
else:
mmask = core.std.Levels(medium, th_med, th_high, 1.0, (1 << clip.format.bits_per_sample) - 1, 0)
dmask = core.std.Levels(medium, th_low, th_med, 1.0, (1 << clip.format.bits_per_sample) - 1, 0)
output = core.std.MaskedMerge(bright, medium, mmask, planes=planes, first_plane=luma)
output = core.std.MaskedMerge(output, dark, dmask, planes=planes, first_plane=luma)
return output
__________________
Intel i7-6700K + Noctua NH-D15 + Z170A XPower G. Titanium + Kingston HyperX Savage DDR4 2x8GB + Radeon RX580 8GB DDR5 + ADATA SX8200 Pro 1 TB + Antec EDG750 80 Plus Gold Mod + Corsair 780T Graphite
Last edited by Overdrive80; 4th October 2015 at 02:08.
|