nx_microscan_lib.nx
buildroot/runtime/nx_microscan_lib.nx
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
imports: nx_syscalls.nxnx_vecmath.nx
imported by: nx_microscan_gate.nx
structs
| none |
consts
| 28 | const MS_D2_INF: i64 = 1000000000 |
| 29 | const MS_PERMIL: i64 = 1000 |
| 30 | const MS_MILLI: i64 = 1000 |
| 33 | const MS_MILLI2: i64 = 1000000 |
| 37 | const MS_REG_DECOUPLED: i64 = 0 |
| 38 | const MS_REG_PARTIAL: i64 = 1 |
| 39 | const MS_REG_BOUND: i64 = 2 |
| 40 | const MS_REG_UNMEASURABLE: i64 = 3 |
| 44 | const MS_REG_K_BOUND: i64 = 4 |
| 45 | const MS_REG_K_CHANCE: i64 = 2 |
| 53 | const MS_REG_MIN_EXPECT: i64 = 10 |
| 59 | const MS_REG_POISSON_PERMIL: i64 = 500 |
| 60 | const MS_REG_LATTICE_PERMIL: i64 = 1000 |
functions
| 62 | func ms_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 71 | func ms_is_peak(f: *i64, w: i64, h: i64, x: i64, y: i64, thresh: i64) -> i64 called by 1: ms_features |
| 105 | func ms_features(f: *i64, w: i64, h: i64, thresh: i64, xs: *i64, ys: *i64, cap: i64) -> i64 |
| 129 | func ms_period_texels(n_feat: i64, w: i64, h: i64) -> i64 |
| 135 | func ms_period_um(n_feat: i64, w: i64, h: i64, texel_um: i64) -> i64 |
| 145 | func ms_nn_mean_milli(xs: *i64, ys: *i64, n: i64) -> i64 |
| 172 | func ms_regularity_permil(nn_mean_milli: i64, period_texels: i64) -> i64 called by 1: main |
| 182 | func ms_coverage_permil(f: *i64, w: i64, h: i64, thresh: i64) -> i64 called by 1: main |
| 197 | func ms_hit_permil(f: *i64, w: i64, h: i64, thresh: i64, px: *i64, py: *i64, n: i64) -> i64 called by 1: main |
| 222 | func ms_reg_verdict(hit_permil: i64, chance_permil: i64, n_points: i64) -> i64 called by 1: main |
| 243 | func ms_block_means(f: *i64, w: i64, h: i64, bs: i64, out: *i64, cap: i64) -> i64 called by 1: main |
| 275 | func ms_robust(v: *i64, n: i64, scratch: *i64, out2: *i64) -> i64 |
| 320 | func ms_anom_count(v: *i64, n: i64, med: i64, mad: i64, k_milli: i64) -> i64 |
| 337 | func ms_worst_idx(v: *i64, n: i64, med: i64) -> i64 |
| 354 | func ms_min_loc(f: *i64, n: i64, out_idx: *i64) -> i64 called by 1: main |