"""Contract smoke test: denoise the baked movie, assert PSNR improves, save PNG.""" from __future__ import annotations import json import sys from PIL import Image from core.io import APP_TMP_DIR, load_image_from_any from core.processing import simulate_full def main() -> int: tif = APP_TMP_DIR / "example.tif" if not tif.exists(): import scripts.make_example as me me.main() movie = load_image_from_any(str(tif)) r = simulate_full(movie, engine="fast", pre=5, post=5, omit=0, source_path=str(tif)) rep = r["report"] assert r["summary"].ndim == 3 and r["summary"].shape[2] == 3, "summary not RGB" assert "psnr_noisy_db" in rep, "no ground-truth metrics (clean sidecar missing)" assert rep["psnr_denoised_db"] > rep["psnr_noisy_db"], \ "temporal-neighbor denoising did not improve PSNR" Image.fromarray(r["summary"]).save(APP_TMP_DIR / "smoke_summary.png") print("REPORT:", json.dumps(rep)) return 0 if __name__ == "__main__": sys.exit(main())