Add frame directory comparison tool
This commit is contained in:
parent
1059b9f5d6
commit
d8fd04bce4
1 changed files with 29 additions and 0 deletions
29
tools/compare_frame_dirs.py
Normal file
29
tools/compare_frame_dirs.py
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
"""Compare two directories of same-sized PNG frames."""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("a", type=Path)
|
||||||
|
parser.add_argument("b", type=Path)
|
||||||
|
parser.add_argument("--frames", type=int, required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
for index in range(args.frames):
|
||||||
|
a = np.asarray(Image.open(args.a / f"frame_{index:04d}.png")).astype(np.int16)
|
||||||
|
b = np.asarray(Image.open(args.b / f"frame_{index:04d}.png")).astype(np.int16)
|
||||||
|
diff = np.abs(a - b)
|
||||||
|
rows.append((index, int(diff.max()), float(diff.mean()), float(np.percentile(diff, 99))))
|
||||||
|
|
||||||
|
print({
|
||||||
|
"frames": args.frames,
|
||||||
|
"max": max(row[1] for row in rows),
|
||||||
|
"mean": sum(row[2] for row in rows) / len(rows),
|
||||||
|
"top_max": sorted(rows, key=lambda row: row[1], reverse=True)[:10],
|
||||||
|
"top_mean": sorted(rows, key=lambda row: row[2], reverse=True)[:10],
|
||||||
|
})
|
||||||
Loading…
Add table
Reference in a new issue