nx_scene_through_aperture.nx
buildroot/runtime/nx_scene_through_aperture.nx
about
nx_scene_through_aperture.nx -- Tier 6 background-coherence detector.
User feedback 2026-05-16: "the car isnt real and the background
is a mess". AI image-gen frequently fails the SCENE-THROUGH-
FRAMED-APERTURE check: when looking through a window or door,
the content visible beyond should follow physical rules:
- sharper foreground, blurrier background (depth-of-field)
- cooler / hazier colors (atmospheric perspective)
- consistent perspective (vanishing lines align with frame)
- recognizable objects, not arbitrary blobs (edge-density
distribution typical of real scenes)
AI puts random fragments through windows because the gen model
has no scene-coherence prior beyond local pixel statistics.
Substrate's answer: measure the four physics-grounded
signatures and emit a sealed verdict.
Inputs: caller pre-extracts the APERTURE region (window/door
bounding box content) and the IMMEDIATE FOREGROUND region
(interior wall / dashboard / face beside window). Computes:
sharpness_ratio_q10 = sharpness(aperture) / sharpness(foreground)
color_temp_shift = mean(aperture_b - aperture_r) - mean(foreground_b - foreground_r)
edge_density_q10 = edge_count(aperture) / aperture_pixels
edge_uniformity_q10 = std(local_edge_density) / mean(local_edge_density)
Physics expectations for real-photo background:
sharpness_ratio in (0.2, 0.8) -- background blurrier
color_temp_shift > 0 -- background bluer (atmospheric)
edge_density in (0.05, 0.30) -- some structure, not flat, not noise
edge_uniformity > 0.4 -- non-uniform distribution
Sealed verdict:
COHERENT -- all 4 checks pass
DEPTH_FAIL -- sharpness ratio outside physical range
ATMOSPHERIC_FAIL -- no color-temp shift
FRAGMENTED -- edge metrics outside real-scene distribution
IMPLAUSIBLE -- 3+ checks fail (likely AI background)
genealogy_id: substrate_scene_through_aperture_2026_05_16
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_runtime.nxnx_tier.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 72 | struct NxApertureResult |
consts
| 53 | const NX_STA_Q10: nx_int = 1024 |
| 56 | const NX_STA_COHERENT: nx_int = 0 |
| 57 | const NX_STA_DEPTH_FAIL: nx_int = 1 |
| 58 | const NX_STA_ATMOSPHERIC_FAIL: nx_int = 2 |
| 59 | const NX_STA_FRAGMENTED: nx_int = 3 |
| 60 | const NX_STA_IMPLAUSIBLE: nx_int = 4 |
| 63 | const NX_STA_SHARP_MIN_Q10: nx_int = 205 // 0.20 |
| 64 | const NX_STA_SHARP_MAX_Q10: nx_int = 819 // 0.80 |
| 65 | const NX_STA_COLOR_MIN_SHIFT: nx_int = 0 // any non-negative shift acceptable; deep negative = fail |
| 66 | const NX_STA_EDGE_DENS_MIN_Q10: nx_int = 51 // 0.05 |
| 67 | const NX_STA_EDGE_DENS_MAX_Q10: nx_int = 307 // 0.30 |
| 68 | const NX_STA_EDGE_UNIFORM_MIN_Q10: nx_int = 410 // 0.40 |
| 82 | const NX_STA_RESULT_BYTES: nx_size = 64 |
| 85 | const NX_STA_BIT_SHARPNESS: nx_int = 0 |
| 86 | const NX_STA_BIT_COLOR: nx_int = 1 |
| 87 | const NX_STA_BIT_EDGE_DENSITY: nx_int = 2 |
| 88 | const NX_STA_BIT_EDGE_UNIFORM: nx_int = 3 |
functions
| 97 | func nx_aperture_classify( |
| 183 | func main() -> nx_int calls 1: nx_aperture_classify |