code wiki / _hdl_build / nx_reader_panels.nx

nx_reader_panels.nx

buildroot/runtime/_hdl_build/nx_reader_panels.nx

14986 B341 linesdepth 10pulls 45 transitivereach 2 importersview sourcekind librarytopic reader
docsdependenciesstructsconstsfunctions

about

nx_reader_panels.nx -- SOVEREIGN comic/manga PANEL DETECTOR (reader census SC04 guided-view auto panel detection + SC17 auto-zoom-to-panel; ComiXology-class "intelligent zoom to what's happening"). Given one page image (JPEG or PNG), finds the panels: grayscale -> integer OTSU binarize (ink vs paper) -> recursive X-Y GUTTER-CUT (find the widest interior run of near-inkless columns/rows, split there, iterate with an explicit stack -- no recursion) -> trim each leaf to its ink bounding box -> READING ORDER (band by vertical overlap, then right-to-left for manga rtl=1 / left-to-right rtl=0). Emits panels.json next to the tile pyramid's dz.json, so the viewer zooms panel-to-panel and fetches only that rect's tiles. Panel rects are page-pixel coordinates = resolution-independent ratios for the viewer. Pure integer classical CV (NO ML deps), composes the proven universal decoder nx_img_bytes_to_rgb. LIB (no main) -- nx_reader_panels_gate drives rp_detect and rp_emit directly. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_img_bytes_to_rgb.nx nx_reader_panels.nx nx_reader_page_prep.nx nx_reader_panels_gate.nx

imports: nx_syscalls.nxnx_img_bytes_to_rgb.nx

imported by: nx_reader_page_prep.nxnx_reader_panels_gate.nx

structs

none

consts

13const RP_MAGIC_1000000: i64 = 1000000
14const RP_MAGIC_8192: i64 = 8192
15const RP_MAGIC_1024: i64 = 1024
17const RP_MAXP: i64 = 64 // max panels per page
18const RP_GUT_PERMIL: i64 = 10 // a gutter row/col has <= 1.0% ink (tolerates JPEG ringing)
19const RP_MIN_DIM: i64 = 24 // min panel width/height (px)
20const RP_MIN_INK: i64 = 100 // min ink pixels for a leaf to count as a panel

functions

22func rp_ap_str(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[o + i] = s[i]; i = i + 1 } return o + i }
called by 1: rp_emit
23func rp_ap_num(dst: *u8, o: i64, v: i64) -> i64
called by 1: rp_emit calls 1: sys_mmap
34func rp_otsu(hist: *i64, total: i64) -> i64
called by 1: rp_ink_map
63func rp_ink_map(rgb: *u8, W: i64, H: i64, ink: *u8) -> i64
called by 1: rp_detect calls 2: sys_mmaprp_otsu
95func rp_rowink(ink: *u8, W: i64, y: i64, x0: i64, x1: i64) -> i64
103func rp_trim(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64, out4: *i64) -> i64
called by 1: rp_detect calls 2: rp_colinkrp_rowink
123func rp_gutter_cols(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64, out2: *i64) -> i64
called by 1: rp_detect calls 1: rp_colink
149func rp_gutter_rows(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64, out2: *i64) -> i64
called by 1: rp_detect calls 1: rp_rowink
175func rp_rect_ink(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64) -> i64
called by 1: rp_detect calls 1: rp_rowink
185func rp_order(pan: *i64, n: i64, rtl: i64) -> i64
called by 1: rp_detect calls 1: sys_mmap
239func rp_detect(rgb: *u8, W: i64, H: i64, rtl: i64, pan: *i64) -> i64
305func rp_emit(src: *u8, outdir: *u8, rtl: i64) -> i64