code wiki / (root) / nx_natstat.nx

nx_natstat.nx

buildroot/runtime/nx_natstat.nx

19321 B472 linesdepth 2pulls 4 transitivereach 9 importersview sourcekind librarytopic natstat
docsdependenciesstructsconstsfunctions

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 2 imports · 9 importers

nx_syscalls.nx nx_vecmath.nx nx_natstat.nx nx_engine_scene_gate.nx nx_face_project_gate.nx nx_face_vs_target.nx nx_grade.nx nx_natstat_corpus.nx nx_natstat_hardcases.nx nx_natstat_optimize.nx nx_natstat_redteam_gate.nx nx_render_judge_gate.nx

imports: nx_syscalls.nxnx_vecmath.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

11const K_MAGIC_65536: i64 = 65536
12const K_MAGIC_3200: i64 = 3200
13const K_MAGIC_6500: i64 = 6500

functions

15func ns_lum(g: i64) -> i64 { return ((g & 255) + ((g >> 8) & 255) + ((g >> 16) & 255)) / 3 }
16func ns_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
17func ns_isqrt(v: i64) -> i64 { return vm_isqrt(v) }
22func ns_mscn_rho(fb: *i64, w: i64, h: i64) -> i64
63func ns_mscn_fill(fb: *i64, w: i64, h: i64, mbuf: *i64) -> i64
called by 1: ns_assess calls 2: ns_lumns_isqrt
94func ns_mscn_rho_buf(mbuf: *i64, w: i64, h: i64) -> i64
called by 1: ns_assess calls 1: ns_abs
116func ns_mscn_pair(mbuf: *i64, w: i64, h: i64, dx: i64, dy: i64) -> i64
called by 1: ns_assess
134func ns_detail(fb: *i64, w: i64, h: i64) -> i64
155func ns_local_std(fb: *i64, w: i64, x: i64, y: i64) -> i64
called by 1: ns_grad_kurt calls 2: ns_lumns_isqrt
177func ns_grad_kurt(fb: *i64, w: i64, h: i64) -> i64
218func ns_colorful(fb: *i64, w: i64, h: i64) -> i64
called by 2: ns_assessmain calls 1: ns_isqrt
254func ns_ai_periodicity(fb: *i64, w: i64, h: i64) -> i64
called by 2: ns_assessmain calls 2: ns_lumns_abs
276func ns_down2(fb: *i64, w: i64, h: i64, out: *i64) -> i64
298func ns_scale_spread(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64) -> i64
321func ns_band(v: i64, lo: i64, hi: i64, edge: i64) -> i64
called by 2: ns_assessmain
335func ns_assess(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64, out: *i64) -> i64
412func ns_photoreal(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64) -> i64
420func ns_coherence(fb: *i64, w: i64, h: i64) -> i64
called by 2: ns_assess2main calls 1: ns_lum
452func ns_assess2(fb: *i64, w: i64, h: i64, buf1: *i64, buf2: *i64, out: *i64) -> i64
called by 2: g_runmain calls 2: ns_assessns_coherence
460func ns_verdict(level: i64) -> *u8
called by 2: maing_run
466func ns_axisname(i: i64) -> *u8
called by 1: main