"""Diagnostic: how different are same-position tiles between consecutive frames, in raw pixel-index terms? Numeric distribution only - no content description. """ from __future__ import annotations from pathlib import Path import numpy as np from PIL import Image PREVIEW_DIR = Path(r"d:\dev\rick-roll-md\encoder-prototype\preview") TILE = 8 def main() -> None: frames = [np.load(p) for p in sorted(PREVIEW_DIR.glob("p*.npy"))] diffs = [] identical = 0 total = 0 for prev, cur in zip(frames, frames[1:]): for ty in range(0, prev.shape[0], TILE): for tx in range(0, prev.shape[1], TILE): a = prev[ty : ty + TILE, tx : tx + TILE] b = cur[ty : ty + TILE, tx : tx + TILE] total += 1 if np.array_equal(a, b): identical += 1 else: diffs.append(int(np.count_nonzero(a != b))) # pixels differing, of 64 diffs_arr = np.array(diffs) print(f"tile-position pairs compared: {total}") print(f"identical (0 pixels differ): {identical} ({100 * identical / total:.1f}%)") print(f"of the rest, pixels-differing-of-64 distribution:") for pct in (10, 25, 50, 75, 90, 99): print(f" p{pct}: {np.percentile(diffs_arr, pct):.0f}") print(f" mean: {diffs_arr.mean():.1f}") for threshold in (1, 2, 4, 8, 16): within = int(np.count_nonzero(diffs_arr <= threshold)) + identical print(f"within {threshold} px of 64 differing: {within} ({100 * within / total:.1f}%)") if __name__ == "__main__": main()