nx_subsurface_warmth.nx
buildroot/runtime/nx_subsurface_warmth.nx
about
nx_subsurface_warmth.nx -- detect subsurface scatter (SSS) by R/G ratio in shadows.
Real skin transmits red wavelength deeper than green/blue. In shadow
regions (low overall luminance), real skin shows ELEVATED red-to-green
ratio relative to the lit side. Mannequin renders / SDXL plastic
renders show flat R:G ratio across light and shadow.
Math:
1. Pick skin-mask pixels with luminance below median (shadow side).
2. Compute mean R, mean G across those pixels.
3. Mean R / Mean G in Q10. SSS-positive when > 1100 (≈1.075).
4. Score Q10: how far above the SSS threshold.
Output flat-array (result[]):
result[0] = shadow_pixel_count
result[1] = mean_R_q10 (mean R*4 to keep precision)
result[2] = mean_G_q10
result[3] = R_to_G_q10 (ratio in Q10)
result[4] = sss_score_q10 (0=no SSS, 1024=strong SSS)
result[5] = verdict (0=MANNEQUIN, 1=SLIGHT, 2=NATURAL)
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_image.nx
imported by: nx_mannequin_index.nxnx_mannequin_index_test.nx
structs
| none |
consts
| 31 | const NX_SSS_RES_COUNT: i64 = 0 |
| 32 | const NX_SSS_RES_MEAN_R: i64 = 1 |
| 33 | const NX_SSS_RES_MEAN_G: i64 = 2 |
| 34 | const NX_SSS_RES_RATIO: i64 = 3 |
| 35 | const NX_SSS_RES_SCORE: i64 = 4 |
| 36 | const NX_SSS_RES_VERDICT: i64 = 5 |
| 37 | const NX_SSS_RES_FIELDS: i64 = 6 |
| 39 | const NX_SSS_VERDICT_MANNEQUIN: i64 = 0 // ratio ≈ 1.0 (flat) |
| 40 | const NX_SSS_VERDICT_SLIGHT: i64 = 1 // 1.05..1.075 |
| 41 | const NX_SSS_VERDICT_NATURAL: i64 = 2 // > 1.075 |
| 43 | const NX_SSS_THRESH_NATURAL_Q10: i64 = 1100 // 1.075 in Q10 |
| 44 | const NX_SSS_THRESH_SLIGHT_Q10: i64 = 1075 // 1.05 in Q10 |
functions
| 48 | func nx_sss_luminance_median(rgb: *Image, mask: *Image) -> i64 |
| 88 | func nx_subsurface_warmth(rgb: *Image, mask: *Image, result: *i64) -> i64 |