20.03.2024, 18:00
Okay, it did appear to good to be true. ![Smile Smile](https://forum.selur.net/images/smilies/smile.png)
About the motion mask thing:
Cu Selur
![Smile Smile](https://forum.selur.net/images/smilies/smile.png)
About the motion mask thing:
Code:
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmotionmask.dll")
import math
def vs_clip_color_stabilizer(clip: vs.VideoNode = None, nframes: int = 5, mode: str = 'center', scenechange: bool = True) -> vs.VideoNode:
if nframes < 3 or nframes > 31:
raise ValueError("deoldify: number of frames must be in range: 3-31")
if mode not in ['left', 'center', 'right']:
raise ValueError("deoldify: mode must be 'left', 'center', or 'right'.")
# convert the clip format for AverageFrames to YUV
clip_yuv = clip.resize.Bicubic(format=vs.YUV444PS, matrix_s="709", range_s="limited")
if nframes%2==0:
nframes +=1
N = max(3, min(nframes, 31))
Nh = round((N-1)/2)
Wi = math.trunc(100.0/N)
if mode in ['left', 'right']:
Wi = 2*Wi
Wc = 100-(Nh)*Wi
else:
Wc = 100-(N-1)*Wi
weight_list = list()
for i in range(0, Nh):
if mode in ['left', 'center']:
weight_list.append(Wi)
else:
weight_list.append(0)
weight_list.append(Wc)
for i in range(0, Nh):
if mode in ['right', 'center']:
weight_list.append(Wi)
else:
weight_list.append(0)
clip_yuv = vs.core.misc.AverageFrames(clip_yuv, weight_list, scenechange = True, planes=[1,2])
# convert the clip format for deoldify to RGB24
clip_rgb = clip_yuv.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="limited", dither_type="error_diffusion")
return clip_rgb
# do filtering
# clip = deoldify ...
# do stabilization
clipFiltered = vs_clip_color_stabilizer(clip, nframes = 31)
# calculate motion mask on GrayImage
clipMask = clipFiltered
clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY8, matrix_s="470bg", range_s="limited")
clipMask = core.motionmask.MotionMask(clip=clipMask, th1=10, th2=10, tht=15) # these are the defaults
clipMask = core.std.InvertMask(clipMask) # invert so that the not moving parts are white
# merge in YUV color space
clipMask = core.resize.Bicubic(clip=clipMask, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # MotionMask
Cu Selur