Skip to content

Commit

Permalink
Add GrainPP.NormBrightness
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Feb 5, 2024
1 parent 6f78cd7 commit e6e3621
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vsdeband/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ class GrainPP(_gpp):
def Bump(cls, strength: float = 0.1) -> GrainPP:
return cls('x[-1,1] x - {strength} * x +', KwargsT(strength=strength + 1.0))

@classmethod
def NormBrightness(cls) -> ResolverTwoClipsArgs:
def _resolve(grained: vs.VideoNode) -> vs.VideoNode:
for i in range(grained.format.num_planes):
grained = grained.std.PlaneStats(plane=i, prop=f'PS{i}')

if get_sample_type(grained) is vs.FLOAT:
return norm_expr(grained, 'x x.PS{plane_idx}Average -')

return norm_expr(grained, 'x range_diff range_size / x.PS{plane_idx}Average - range_size * +')

return _resolve


FadeLimits = tuple[int | Iterable[int] | None, int | Iterable[int] | None]
GrainPostProcessT = ResolverOneClipArgs | ResolverTwoClipsArgs | str | GrainPP | GrainPP.Resolver
Expand Down

0 comments on commit e6e3621

Please sign in to comment.