nx_shadow_integration.nx
buildroot/runtime/nx_shadow_integration.nx
about
nx_shadow_integration.nx -- Best Compositing (shadow half).
Real subjects in real scenes cast shadows onto environment objects.
AI renders often drop the shadow → subject reads "pasted on".
Detector measures: in the region around the subject's silhouette
edge, is there a darkening band ON the environment side that
matches what a subject-cast shadow would look like?
Math:
1. Define a band along the subject's outer edge on the BG side.
2. Compare mean luminance INSIDE that band vs background baseline
luminance further away.
3. Real shadow: band is 10-25% darker than baseline.
4. No shadow: band is similar to baseline.
Inputs: gray image + subject_mask + env_baseline_bbox.
Output flat-array:
result[0] band_mean_Y
result[1] baseline_mean_Y
result[2] shadow_depth_pct (baseline - band) * 100 / baseline
result[3] verdict
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_image.nx
imported by: nx_oscar_batch_test.nx
structs
| none |
consts
| 33 | const NX_SHADOW_RES_BAND_Y: i64 = 0 |
| 34 | const NX_SHADOW_RES_BASELINE_Y: i64 = 1 |
| 35 | const NX_SHADOW_RES_DEPTH_PCT: i64 = 2 |
| 36 | const NX_SHADOW_RES_VERDICT: i64 = 3 |
| 37 | const NX_SHADOW_RES_FIELDS: i64 = 4 |
| 39 | const NX_SHADOW_V_MISSING: i64 = 0 // < 5% depth |
| 40 | const NX_SHADOW_V_WEAK: i64 = 1 // 5-10% |
| 41 | const NX_SHADOW_V_NATURAL: i64 = 2 // 10-25% |
| 42 | const NX_SHADOW_V_OVERDARK: i64 = 3 // > 25% |
functions
| 47 | func nx_shadow_mean_y_masked(rgb: *Image, mask: *Image, |
| 84 | func nx_shadow_integration(rgb: *Image, subject_mask: *Image, |