Skip to content

Commit

Permalink
Add shimmer_soothe
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Oct 19, 2023
1 parent ece837a commit 3c427cd
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion vsrgtools/sharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
__all__ = [
'unsharpen',
'unsharp_masked',
'limit_usm'
'limit_usm',
'shimmer_soothe'
]


Expand Down Expand Up @@ -71,3 +72,22 @@ def limit_usm(
sharp = norm_expr([clip, blurred], 'x dup y - +', planes)

return limit_filter(sharp, clip, thr=thr, elast=elast, bright_thr=bright_thr)


def shimmer_soothe(
sharp: vs.VideoNode, orig: vs.VideoNode, strength: int = 75, tr: int = 1,
scenechange: bool = False, planes: PlanesT = 0
) -> vs.VideoNode:
diff = orig.std.MakeDiff(sharp, planes)

strength = 100 - max(min(100, strength), 0)

soft_diff = diff.std.AverageFrames([1] * (tr * 2 + 1), None, scenechange, planes)

limit_diff = norm_expr([diff, soft_diff], [
'x range_diff - y range_diff - xor x range_diff - 100 / {strength} '
f'* range_diff + x range_diff - abs y range_diff - abs > x {strength} '
f'* y 100 {strength} - * + 100 / x ? ?'
], planes, strength=strength)

return norm_expr([orig, limit_diff], 'x y range_diff - -', planes)

0 comments on commit 3c427cd

Please sign in to comment.