"""Generate deterministic test pairs and a browsable report; run from repo root.""" from pathlib import Path import html import json import cv2 import numpy as np from backend.registration import register, RegistrationError from synthetic_cases import CASE_NAMES, make_case, mapping_errors out = Path('reports') out.mkdir(exist_ok=True) ref = cv2.resize(cv2.imread('fixtures/synthetic-iris.png'), (1000, 1000)) cv2.imwrite(str(out/'reference.png'), ref) rows = [] cards = [] for name in CASE_NAMES: moving, truth_points, moving_points = make_case(ref, name) cv2.imwrite(str(out/f'{name}-moving.jpg'), moving) try: result = register(ref, moving, return_maps=True) errors = mapping_errors(result['sampling_map'], truth_points, moving_points) row = dict(case=name, median_error_px=float(np.median(errors)), p95_error_px=float(np.percentile(errors,95)), status='PASS' if np.percentile(errors,95)<1 else 'LIMITATION', **result['metrics']) for key, img in result.items(): if key not in ('metrics', 'sampling_map'): cv2.imwrite(str(out/f'{name}-{key}.png'), img) cards.append(f'

{name}: {row["status"]}

Independent grid error: median {row["median_error_px"]:.3f}px · p95 {row["p95_error_px"]:.3f}px

'+''.join(f'
{key}
' for key,ext in [('moving','jpg'),('global_aligned','png'),('overlay','png'),('composite','png')])+'
') except RegistrationError as exc: row = dict(case=name, status='REJECTED', reason=str(exc)) cards.append(f'

{name}: REJECTED

{html.escape(str(exc))} No composite produced.

Moving image with known local distortion
Reference
') rows.append(row) (out/'metrics.json').write_text(json.dumps(rows, indent=2)) (out/'index.html').write_text('Synthetic registration benchmark

Synthetic iris registration benchmark

One AI-generated fixture, deterministic transformations. These are not real client photographs. Error is measured in moving-image pixels using the complete backward sampling map at independent known-coordinate iris grid points, not fitting matches. PASS means p95 < 1 pixel at 1000 × 1000. Click images for full resolution.

Reference image · Full measurements'+''.join(cards)) print(json.dumps([{k:r[k] for k in ['case','status','median_error_px','p95_error_px'] if k in r} for r in rows], indent=2))