code wiki / (root) / nx_microscan_lib.nx

nx_microscan_lib.nx

buildroot/runtime/nx_microscan_lib.nx

16341 B366 linesdepth 2pulls 4 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_microscan_lib.nx -- INVERSE MICRO-SURFACE ANALYSIS: infer a surface's micro-STRUCTURE, and its DEFECTS, from the field itself. The estate already GENERATES micro-relief (nx_relief_lib owns the forward law: three bands and a jittered-grid pore layer). Nothing ever read a field back. This is that half, and it is deliberately the INVERSE of a generator rather than a second generator. WHY THIS IS A LEAF THAT KNOWS NOTHING ABOUT SKIN. Every function below takes a plain field of i64 samples, a width, a height and the physical size of one sample. It has no pore constant, no skin constant and no relief import -- so the same analyser reads a skin height map, a machined surface, or a field of WALL THICKNESSES off a mesh, and the teapot-leak question is the same call as the pore question with a different quantity in the array. A ruler that imported the thing it measures could not be pointed anywhere else, and its round-trip test would be circular. THE FOUR QUESTIONS IT ANSWERS, all as NUMBERS and never as a diagnosis: 1. WHAT IS THE PERIOD of the discrete features carried here? ms_period_texels / ms_period_um 2. IS THIS A LATTICE AT ALL, or a random scatter? ms_regularity_permil 3. ARE TWO LAYERS BOUND OR INDEPENDENT? ms_hit_permil / ms_reg_verdict 4. WHERE DOES THIS FIELD DEPART FROM ITSELF? ms_robust / ms_anom_count / ms_min_loc DECLARED SCOPE, because this is the half that is usually overclaimed: question 4 emits CANDIDATE REGIONS WITH SCORES. It is an outlier finder over a field. It is NOT a diagnosis of anything and no clinical reading may be built on it -- the resolution bar is stated in the gate's verdict note. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_vecmath.nx nx_microscan_lib.nx nx_microscan_gate.nx

imports: nx_syscalls.nxnx_vecmath.nx

imported by: nx_microscan_gate.nx

structs

none

consts

28const MS_D2_INF: i64 = 1000000000
29const MS_PERMIL: i64 = 1000
30const MS_MILLI: i64 = 1000
33const MS_MILLI2: i64 = 1000000
37const MS_REG_DECOUPLED: i64 = 0
38const MS_REG_PARTIAL: i64 = 1
39const MS_REG_BOUND: i64 = 2
40const MS_REG_UNMEASURABLE: i64 = 3
44const MS_REG_K_BOUND: i64 = 4
45const MS_REG_K_CHANCE: i64 = 2
53const MS_REG_MIN_EXPECT: i64 = 10
59const MS_REG_POISSON_PERMIL: i64 = 500
60const MS_REG_LATTICE_PERMIL: i64 = 1000

functions

62func ms_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
71func ms_is_peak(f: *i64, w: i64, h: i64, x: i64, y: i64, thresh: i64) -> i64
called by 1: ms_features
105func ms_features(f: *i64, w: i64, h: i64, thresh: i64, xs: *i64, ys: *i64, cap: i64) -> i64
called by 1: main calls 1: ms_is_peak
129func ms_period_texels(n_feat: i64, w: i64, h: i64) -> i64
called by 1: main calls 1: vm_isqrt
135func ms_period_um(n_feat: i64, w: i64, h: i64, texel_um: i64) -> i64
called by 1: main calls 1: vm_isqrt
145func ms_nn_mean_milli(xs: *i64, ys: *i64, n: i64) -> i64
called by 1: main calls 1: vm_isqrt
172func ms_regularity_permil(nn_mean_milli: i64, period_texels: i64) -> i64
called by 1: main
182func ms_coverage_permil(f: *i64, w: i64, h: i64, thresh: i64) -> i64
called by 1: main
197func ms_hit_permil(f: *i64, w: i64, h: i64, thresh: i64, px: *i64, py: *i64, n: i64) -> i64
called by 1: main
222func ms_reg_verdict(hit_permil: i64, chance_permil: i64, n_points: i64) -> i64
called by 1: main
243func ms_block_means(f: *i64, w: i64, h: i64, bs: i64, out: *i64, cap: i64) -> i64
called by 1: main
275func ms_robust(v: *i64, n: i64, scratch: *i64, out2: *i64) -> i64
called by 1: main calls 1: ms_abs
320func ms_anom_count(v: *i64, n: i64, med: i64, mad: i64, k_milli: i64) -> i64
called by 1: main calls 1: ms_abs
337func ms_worst_idx(v: *i64, n: i64, med: i64) -> i64
called by 1: main calls 1: ms_abs
354func ms_min_loc(f: *i64, n: i64, out_idx: *i64) -> i64
called by 1: main