Skip to content

Instantly share code, notes, and snippets.

@wiwaz
Last active November 26, 2022 17:00
Show Gist options
  • Save wiwaz/8b39e4332d0a627fba32b07de94c4a5e to your computer and use it in GitHub Desktop.
Save wiwaz/8b39e4332d0a627fba32b07de94c4a5e to your computer and use it in GitHub Desktop.
def lehmer_merge(clip, lowpass=lambda i: core.std.BoxBlur(i, hradius=3, vradius=3, hpasses=2, vpasses=2)):
count = len(clip)
expr = ""
for i in range(count):
expr += f"src{i} src{count + i} - D{i}! "
for v in range(2):
for i in range(count):
expr += f"D{i}@ {v + 2} pow "
expr += "+ " * (count - 1) + f"P{v}! "
for i in range(count):
expr += f"src{count + i} "
expr += "+ " * (count - 1) + f"{count} / "
expr += "P0@ 0 = 0 P1@ P0@ / ? +"
blur = [lowpass(i) for i in clip]
return core.akarin.Expr(clip + blur, expr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment