11 lines
655 B
Python
11 lines
655 B
Python
"""Real preview regression: background grain must not dominate the display."""
|
|
from pathlib import Path
|
|
import struct,sys,json
|
|
import numpy as np
|
|
from PIL import Image
|
|
path=Path(sys.argv[1] if len(sys.argv)>1 else 'docs/diagnostics/ngc7000-after.bin')
|
|
data=path.read_bytes();w,h=struct.unpack('<ii',data[:8]);a=np.frombuffer(data[8:],dtype=np.uint8).reshape(h,w).astype(float)
|
|
grain=float(np.median(np.abs(a[:,1:]-a[:,:-1]))/255)
|
|
Image.fromarray(a.astype(np.uint8)).save(path.with_suffix('.png'))
|
|
print(json.dumps({'file':str(path),'medianDisplay':float(np.median(a)/255),'adjacentGrain':grain,'pass':grain<.06},indent=2))
|
|
sys.exit(0 if grain<.06 else 1)
|