Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from vapoursynth import core
- def MMFilter(clips, mode='min', planes=None):
- """ Min/Max Filter
- For "clips" supply an array of 3: a source clip and 2 filtered clips
- When mode='max' - Take the largest filtered difference, or the mean difference if one is darker and the other brighter
- When mode='min' - Take the smallest filtered difference, or the source pixel if one is darker and the other brighter
- """
- planes = list(range(clips[0].format.num_planes)) if planes is None else [planes] if isinstance(planes, int) else planes
- expr = 'x y - x z - * 0 < {} x y - abs x z - abs < {} ? ?'.format('y z + 2 /' if mode=='max' else 'x', 'z y' if mode=='max' else 'y z')
- expr = [expr if i in planes else '' for i in range(clips[0].format.num_planes)]
- return core.std.Expr(clips, expr)
- # Example (MinBlur):
- # clips = [clip, clip.rgvs.Removegrain(11), clip.std.Median()]
- # MMFilter(clips, 'min')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement