nx_natstat.nx
buildroot/runtime/nx_natstat.nx
about
nx_natstat.nx -- NATURAL-IMAGE-STATISTICS photoreal metric = the REVERSE AI JUDGE. Real photographs have a
signature our old critic missed: DETAIL AT EVERY SCALE (a ~1/f amplitude spectrum -> roughly EQUAL detail
energy per octave). Clay/CG fails it two ways: too SMOOTH (fine + mid octaves empty) or GRAIN-ONLY (a spike
at the finest octave, smooth beneath). We measure the multi-scale detail profile + its balance (+ gradient
heavy-tail + colour spread) and return a graded PHOTOREAL LEVEL 0..1000. Uses:
(a) REVERSE JUDGE: maximise this to push Z-Image toward more-real output for games/VR (evaluator-in-reverse);
(b) "USE-AS-PHOTOREAL-TO-LEVEL": even a known-AI image is usable as photoreal up to the level it scores.
Integer, deterministic, no FFT (Laplacian-pyramid octave energies). license_tier: ORIGINAL
dependencies 1 imports · 9 importers
imports: nx_syscalls.nx
imported by: nx_engine_scene_gate.nxnx_face_project_gate.nxnx_face_vs_target.nxnx_grade.nxnx_natstat_corpus.nxnx_natstat_hardcases.nxnx_natstat_optimize.nxnx_natstat_redteam_gate.nxnx_render_judge_gate.nx
structs
| none |
consts
| 10 | const K_MAGIC_65536: i64 = 65536 |
| 11 | const K_MAGIC_3200: i64 = 3200 |
| 12 | const K_MAGIC_6500: i64 = 6500 |
functions
| 14 | func ns_lum(g: i64) -> i64 { return ((g & 255) + ((g >> 8) & 255) + ((g >> 16) & 255)) / 3 } |
| 15 | func ns_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 16 | func ns_isqrt(v: i64) -> i64 { if v <= 0 { return 0 } var x: i64 = v; var y: i64 = (x + 1) / 2; while y < x { x = y; y = (x + v / x) / 2 } return x } |
| 21 | func ns_mscn_rho(fb: *i64, w: i64, h: i64) -> i64 |
| 62 | func ns_mscn_fill(fb: *i64, w: i64, h: i64, mbuf: *i64) -> i64 |
| 93 | func ns_mscn_rho_buf(mbuf: *i64, w: i64, h: i64) -> i64 |
| 115 | func ns_mscn_pair(mbuf: *i64, w: i64, h: i64, dx: i64, dy: i64) -> i64 called by 1: ns_assess |
| 133 | func ns_detail(fb: *i64, w: i64, h: i64) -> i64 |
| 154 | func ns_local_std(fb: *i64, w: i64, x: i64, y: i64) -> i64 |
| 176 | func ns_grad_kurt(fb: *i64, w: i64, h: i64) -> i64 |
| 217 | func ns_colorful(fb: *i64, w: i64, h: i64) -> i64 |
| 253 | func ns_ai_periodicity(fb: *i64, w: i64, h: i64) -> i64 |
| 275 | func ns_down2(fb: *i64, w: i64, h: i64, out: *i64) -> i64 |
| 297 | func ns_scale_spread(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64) -> i64 |
| 320 | func ns_band(v: i64, lo: i64, hi: i64, edge: i64) -> i64 |
| 334 | func ns_assess(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64, out: *i64) -> i64 called by 9: mainmainmaing_runns_photorealns_assess2+3 calls 10: ns_detailns_down2ns_mscn_fillns_mscn_rho_bufns_mscn_pairns_abs+4 |
| 411 | func ns_photoreal(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64) -> i64 |
| 419 | func ns_coherence(fb: *i64, w: i64, h: i64) -> i64 |
| 451 | func ns_assess2(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64, out: *i64) -> i64 |
| 459 | func ns_verdict(level: i64) -> *u8 |
| 465 | func ns_axisname(i: i64) -> *u8 called by 1: main |