nx_img_core.nx
buildroot/runtime/nx_img_core.nx
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
imports: nx_syscalls.nx
imported by: nx_img_core_gate.nxnx_img_threshold.nxnx_ocr_classify_gate.nx
structs
| none |
consts
| 8 | const IMG_FMT: i64 = 0 // dims[]: 2 = P2 (ASCII), 5 = P5 (binary) |
| 9 | const IMG_W: i64 = 1 |
| 10 | const IMG_H: i64 = 2 |
| 11 | const IMG_MAX: i64 = 3 |
functions
| 13 | func img_is_ws(ch: i64) -> i64 called by 1: img_skip_ws |
| 22 | func img_skip_ws(src: *u8, len: i64, p: i64) -> i64 |
| 41 | func img_next_uint(src: *u8, len: i64, pos: *i64) -> i64 |
| 57 | func img_parse_header(src: *u8, len: i64, dims: *i64) -> i64 |
| 77 | func img_pgm_decode(src: *u8, len: i64, pix: *u8, cap: i64, dims: *i64) -> i64 |
| 101 | func img_get(pix: *u8, w: i64, x: i64, y: i64) -> i64 { return pix[y * w + x] as i64 } |
| 102 | func img_set(pix: *u8, w: i64, x: i64, y: i64, v: i64) -> i64 { pix[y * w + x] = v as u8; return 0 } |
| 103 | func img_invert(pix: *u8, npix: i64, maxval: i64) -> i64 called by 1: main |
| 107 | func img_histogram(pix: *u8, npix: i64, hist: *i64) -> i64 |