feisty2
1st October 2015, 16:28
so I was like, writing something like dither_limit_dif16, but different from that, like, an alternative but works differently more or less, anyway, it's called "thr_merge"
AND, I haphazardly found it could be used to do some real chilling night vision stuff besides, like, dither_limit_dif16 sort of thing
import vapoursynth as vs
core = vs.get_core()
def thr_merge (flt, src, ref=None, thr=0.0009765625, elast=None):
ref = src if ref is None else ref
elast = thr / 2 if elast is None else elast
BExp = ["x {thr} {elast} + z - 2 {elast} * / * y {elast} z + {thr} - 2 {elast} * / * +".format (thr=thr, elast=elast)]
BDif = core.std.Expr (src, "0.0")
PDif = core.std.Expr ([flt, src], "x y - 0.0 max")
PRef = core.std.Expr ([flt, ref], "x y - 0.0 max")
PBLD = core.std.Expr ([PDif, BDif, PRef], BExp)
NDif = core.std.Expr ([flt, src], "y x - 0.0 max")
NRef = core.std.Expr ([flt, ref], "y x - 0.0 max")
NBLD = core.std.Expr ([NDif, BDif, NRef], BExp)
BLDD = core.std.Expr ([PBLD, NBLD], ["x y - 0.5 +"])
BLD = core.std.MergeDiff (src, BLDD)
UDN = core.std.Expr ([flt, ref, BLD], ["x y - abs {thr} {elast} - > z x ?".format (thr=thr, elast=elast)])
clip = core.std.Expr ([flt, ref, UDN, src], ["x y - abs {thr} {elast} + < z a ?".format (thr=thr, elast=elast)])
return clip
clp = rule6
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=32, flt=True)
clp2 = core.std.Expr (clp, "0.0")
clp = thr_merge (clp,clp2,thr=0.5, elast=0.32)
clp.set_output ()
before & after
http://i.imgur.com/Fl33z4r.png
http://i.imgur.com/LgNZQr6.png
guess Sparktank's gonna dig this, like, yeah, make the shit reeeeeaaaal tripppppy
and, here's to my first thread as a college freshman
AND, I haphazardly found it could be used to do some real chilling night vision stuff besides, like, dither_limit_dif16 sort of thing
import vapoursynth as vs
core = vs.get_core()
def thr_merge (flt, src, ref=None, thr=0.0009765625, elast=None):
ref = src if ref is None else ref
elast = thr / 2 if elast is None else elast
BExp = ["x {thr} {elast} + z - 2 {elast} * / * y {elast} z + {thr} - 2 {elast} * / * +".format (thr=thr, elast=elast)]
BDif = core.std.Expr (src, "0.0")
PDif = core.std.Expr ([flt, src], "x y - 0.0 max")
PRef = core.std.Expr ([flt, ref], "x y - 0.0 max")
PBLD = core.std.Expr ([PDif, BDif, PRef], BExp)
NDif = core.std.Expr ([flt, src], "y x - 0.0 max")
NRef = core.std.Expr ([flt, ref], "y x - 0.0 max")
NBLD = core.std.Expr ([NDif, BDif, NRef], BExp)
BLDD = core.std.Expr ([PBLD, NBLD], ["x y - 0.5 +"])
BLD = core.std.MergeDiff (src, BLDD)
UDN = core.std.Expr ([flt, ref, BLD], ["x y - abs {thr} {elast} - > z x ?".format (thr=thr, elast=elast)])
clip = core.std.Expr ([flt, ref, UDN, src], ["x y - abs {thr} {elast} + < z a ?".format (thr=thr, elast=elast)])
return clip
clp = rule6
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=32, flt=True)
clp2 = core.std.Expr (clp, "0.0")
clp = thr_merge (clp,clp2,thr=0.5, elast=0.32)
clp.set_output ()
before & after
http://i.imgur.com/Fl33z4r.png
http://i.imgur.com/LgNZQr6.png
guess Sparktank's gonna dig this, like, yeah, make the shit reeeeeaaaal tripppppy
and, here's to my first thread as a college freshman