nx_skinsample_lib.nx
buildroot/runtime/nx_skinsample_lib.nx
about
nx_skinsample_lib.nx -- THE FIRST PHOTO RULER FOR THE TWIN CARD: skin colour MEASURED from a mirrored photograph
(aesthetictwin AT23 rulers skin_L skin_a skin_b ita, 2026-09-16). Decodes the JPEG through the estate's own baseline and
progressive decoder (nx_jpeg_ascii.nx composes nx_jpeg_decode and nx_jpeg_progressive), keeps the pixels a declared skin
chroma rule admits, averages them in LINEAR light (never in gamma bytes), converts the mean to CIE L*a*b* with the transform
constants nx_skin_ita already carries (one colour organ, never two), and takes the individual typology angle through the
estate's fixed-point CORDIC arctangent (nx_fixq30_lib). Every number a card receives from this ruler is MEASURED: method
measured, source the declared reference key, and the receipt prints the mask count beside the mean so a reader can see how
much of the image the value rests on.
WHAT IS CHOSEN, said plainly: the skin mask is the YCbCr chroma rule Cb in [77,127] and Cr in [133,173] (a published
hand-tuned rule, not a model of this subject) with a luma gate that drops clipped shadows and highlights. It admits skin under
most daylight and studio light and also admits skin-coloured backgrounds, sand and wood; the count and the coverage are
therefore PRINTED and journaled with the value, and a region chart (a face or torso window) narrows the mask when the card
names one. What is DERIVED: the sRGB transfer, the D65 matrix, the Lab transform and the ITA definition (Chardon 1991).
LIB, no main. license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 5 imports · 3 importers
imports: nx_syscalls.nxnx_jpeg_ascii.nxnx_skin_ita.nxnx_fixq30_lib.nxnx_twincard_lib.nx
imported by: nx_photomark_lib.nxnx_skinsample.nxnx_skinsample_gate.nx
structs
| none |
consts
| 21 | const SKS_E5: i64 = 100000 |
| 22 | const SKS_E4: i64 = 10000 |
| 23 | const SKS_E3: i64 = 1000 |
| 24 | const SKS_PCT: i64 = 100 |
| 25 | const SKS_TEN: i64 = 10 |
| 27 | const SKS_M_XR: i64 = 4124 |
| 28 | const SKS_M_XG: i64 = 3576 |
| 29 | const SKS_M_XB: i64 = 1805 |
| 30 | const SKS_M_YR: i64 = 2126 |
| 31 | const SKS_M_YG: i64 = 7152 |
| 32 | const SKS_M_YB: i64 = 722 |
| 33 | const SKS_M_ZR: i64 = 193 |
| 34 | const SKS_M_ZG: i64 = 1192 |
| 35 | const SKS_M_ZB: i64 = 9505 |
| 37 | const SKS_F_KNEE: i64 = 886 |
| 40 | const SKS_F_OFF_E5: i64 = 13790 |
| 42 | const SKS_A_MUL: i64 = 5 |
| 43 | const SKS_B_MUL: i64 = 2 |
| 45 | const SKS_YCC_CB_R: i64 = 0 - 16874 |
| 46 | const SKS_YCC_CB_G: i64 = 0 - 33126 |
| 47 | const SKS_YCC_CB_B: i64 = 50000 |
| 48 | const SKS_YCC_CR_R: i64 = 50000 |
| 49 | const SKS_YCC_CR_G: i64 = 0 - 41869 |
| 50 | const SKS_YCC_CR_B: i64 = 0 - 8131 |
| 51 | const SKS_YCC_Y_R: i64 = 29900 |
| 52 | const SKS_YCC_Y_G: i64 = 58700 |
| 53 | const SKS_YCC_Y_B: i64 = 11400 |
| 54 | const SKS_YCC_MID: i64 = 128 |
| 55 | const SKS_CB_LO: i64 = 77 |
| 56 | const SKS_CB_HI: i64 = 127 |
| 57 | const SKS_CR_LO: i64 = 133 |
| 58 | const SKS_CR_HI: i64 = 173 |
| 59 | const SKS_Y_LO: i64 = 30 |
| 60 | const SKS_Y_HI: i64 = 235 |
| 61 | const SKS_BYTE: i64 = 255 |
| 63 | const SKS_L_PIVOT_E3: i64 = 50000 |
| 65 | const SKS_R_L: i64 = 0 |
| 66 | const SKS_R_A: i64 = 1 |
| 67 | const SKS_R_B: i64 = 2 |
| 68 | const SKS_R_COUNT: i64 = 3 |
| 69 | const SKS_R_TOTAL: i64 = 4 |
| 70 | const SKS_R_ITA: i64 = 5 |
| 71 | const SKS_R_N: i64 = 6 |
| 72 | const SKS_BPP: i64 = 3 |
| 73 | const SKS_OK: i64 = 0 |
| 74 | const SKS_E_UNMEASURED: i64 = 0 - 1 |
| 75 | const SKS_E_DECODE: i64 = 0 - 2 |
| 76 | const SKS_E_READ: i64 = 0 - 3 |
| 77 | const SKS_E_EXISTS: i64 = 0 - 4 |
| 78 | const SKS_SIDE_C: *u8 = "C" |
| 79 | const SKS_METHOD: *u8 = "measured" |
functions
| 82 | func sks_ruler_version() -> i64 { return 1 } |
| 85 | func sks_f_e5(t_e5: i64) -> i64 |
| 90 | func sks_lab_of_linear(lr: i64, lg: i64, lb: i64, out3: *i64) -> i64 |
| 103 | func sks_lab_of_rgb(r: i64, g: i64, b: i64, out3: *i64) -> i64 |
| 107 | func sks_is_skin(r: i64, g: i64, b: i64) -> i64 |
| 120 | func sks_ita_deg10(l_e3: i64, b_e3: i64) -> i64 |
| 131 | func sks_measure_rgb(rgb: *u8, w: i64, h: i64, out: *i64) -> i64 |
| 165 | func sks_measure_file(path: *u8, out: *i64) -> i64 |
| 182 | func sks_row(out: *u8, id: *u8, value: i64, refkey: *u8, when: *u8) -> i64 called by 1: sks_card_write |
| 202 | func sks_card_write(slug: *u8, refkey: *u8, when: *u8, res: *i64) -> i64 |