24.03.2024, 12:11
Hello Selur,
sorry to bother you but I have a problem with Vapoursynth that I can't understand.
In order to improve the "chroma limiter", I was thinking to add the possibility to repeat the filter more times (max 5).
To do that I wrote this piece of code
Now the problem:
If I set "tht=0" the motion mask is not applied and I can see the filter working:
Here with steps=1
![[Image: attachment.php?aid=2316]](https://forum.selur.net/attachment.php?aid=2316)
Here with steps=5
![[Image: attachment.php?aid=2317]](https://forum.selur.net/attachment.php?aid=2317)
But if I set "tht" with a value > 1 and < 255, independently from the value I get always the same image:
![[Image: attachment.php?aid=2315]](https://forum.selur.net/attachment.php?aid=2315)
like the Mask was always filled with weights=0
Do you have any idea on the reason ?
Dan
sorry to bother you but I have a problem with Vapoursynth that I can't understand.
In order to improve the "chroma limiter", I was thinking to add the possibility to repeat the filter more times (max 5).
To do that I wrote this piece of code
def _clip_chroma_limiter_ex(clip: vs.VideoNode = None, deviation: float = 0.05, steps: int = 1, tht: int = 10) -> vs.VideoNode:
max_steps = max(min(steps, 5), 1)
clip_limited = vs_clip_chroma_stabilizer(clip, deviation=deviation)
for i in range(1, max_steps):
clip_limited=vs_clip_chroma_stabilizer(clip_limited, deviation=deviation)
if tht < 1 or tht > 255:
return clip_limited
# calculate motion mask
clipMask = clip
clipMask = clipMask.resize.Bicubic(format=vs.GRAY8, matrix_s="470bg", range_s="limited")
clipMask = vs.core.motionmask.MotionMask(clip=clipMask, th1=tht, th2=tht, tht=tht) # pixels with abs(diff) < tht will be black (static parts)
clipMask = vs.core.std.InvertMask(clip=clipMask) # invert so that static parts are white (weight=1)
# merge in YUV color space
clipMask = clipMask.resize.Bicubic(format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
clip_limited = clip_limited.resize.Bicubic(format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
clip = clip.resize.Bicubic(format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
clip = vs.core.std.MaskedMerge(clipa=clip, clipb=clip_limited, mask=clipMask) # MotionMask
# restore RBG24 color space
clip = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="limited", dither_type="error_diffusion")
return clip
Now the problem:
If I set "tht=0" the motion mask is not applied and I can see the filter working:
Here with steps=1
Here with steps=5
But if I set "tht" with a value > 1 and < 255, independently from the value I get always the same image:
like the Mask was always filled with weights=0
Do you have any idea on the reason ?
Dan