code wiki / (root) / nx_img_core.nx

nx_img_core.nx

buildroot/runtime/nx_img_core.nx

4375 B111 linesdepth 2pulls 2 transitivereach 8 importersview sourcekind librarytopic img
docsdependenciesstructsconstsfunctions

about

nx_img_core.nx -- R1 of the SOVEREIGN scanning stack (hardware rung up): raw bytes -> pixels. A sovereign image decoder + pixel buffer, the foundation every later rung (R2 threshold, R3 segment, R4 OCR) stands on. Decodes the netpbm graymap format PGM -- P2 (ASCII) + P5 (binary) -- into a row-major 8-bit grayscale buffer. Netpbm is the trivial, uncompressed, sovereign image format (a scanner or our own capture can emit it, or we convert to it). Integer-exact, zero dependencies. Next rungs read this buffer. license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_img_core.nx nx_img_core_gate.nx nx_img_threshold.nx nx_ocr_classify_gate.nx

imports: nx_syscalls.nx

imported by: nx_img_core_gate.nxnx_img_threshold.nxnx_ocr_classify_gate.nx

structs

none

consts

8const IMG_FMT: i64 = 0 // dims[]: 2 = P2 (ASCII), 5 = P5 (binary)
9const IMG_W: i64 = 1
10const IMG_H: i64 = 2
11const IMG_MAX: i64 = 3

functions

13func img_is_ws(ch: i64) -> i64
called by 1: img_skip_ws
22func img_skip_ws(src: *u8, len: i64, p: i64) -> i64
called by 1: img_next_uint calls 1: img_is_ws
41func img_next_uint(src: *u8, len: i64, pos: *i64) -> i64
57func img_parse_header(src: *u8, len: i64, dims: *i64) -> i64
77func img_pgm_decode(src: *u8, len: i64, pix: *u8, cap: i64, dims: *i64) -> i64
101func img_get(pix: *u8, w: i64, x: i64, y: i64) -> i64 { return pix[y * w + x] as i64 }
called by 2: mainmain
102func img_set(pix: *u8, w: i64, x: i64, y: i64, v: i64) -> i64 { pix[y * w + x] = v as u8; return 0 }
103func img_invert(pix: *u8, npix: i64, maxval: i64) -> i64
called by 1: main
107func img_histogram(pix: *u8, npix: i64, hist: *i64) -> i64
called by 2: mainthr_otsu_of