code wiki / _hdl_build / nx_reader_panels.nx
nx_reader_panels.nx
buildroot/runtime/_hdl_build/nx_reader_panels.nx
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
imports: nx_syscalls.nxnx_img_bytes_to_rgb.nx
imported by: nx_reader_page_prep.nxnx_reader_panels_gate.nx
structs
| none |
consts
| 13 | const RP_MAGIC_1000000: i64 = 1000000 |
| 14 | const RP_MAGIC_8192: i64 = 8192 |
| 15 | const RP_MAGIC_1024: i64 = 1024 |
| 17 | const RP_MAXP: i64 = 64 // max panels per page |
| 18 | const RP_GUT_PERMIL: i64 = 10 // a gutter row/col has <= 1.0% ink (tolerates JPEG ringing) |
| 19 | const RP_MIN_DIM: i64 = 24 // min panel width/height (px) |
| 20 | const RP_MIN_INK: i64 = 100 // min ink pixels for a leaf to count as a panel |
functions
| 22 | func 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 |
| 23 | func rp_ap_num(dst: *u8, o: i64, v: i64) -> i64 |
| 34 | func rp_otsu(hist: *i64, total: i64) -> i64 called by 1: rp_ink_map |
| 63 | func rp_ink_map(rgb: *u8, W: i64, H: i64, ink: *u8) -> i64 |
| 88 | func rp_colink(ink: *u8, W: i64, x: i64, y0: i64, y1: i64) -> i64 |
| 95 | func rp_rowink(ink: *u8, W: i64, y: i64, x0: i64, x1: i64) -> i64 |
| 103 | func rp_trim(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64, out4: *i64) -> i64 |
| 123 | func rp_gutter_cols(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64, out2: *i64) -> i64 |
| 149 | func rp_gutter_rows(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64, out2: *i64) -> i64 |
| 175 | func rp_rect_ink(ink: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64) -> i64 |
| 185 | func rp_order(pan: *i64, n: i64, rtl: i64) -> i64 |
| 239 | func rp_detect(rgb: *u8, W: i64, H: i64, rtl: i64, pan: *i64) -> i64 called by 2: rp_emitmain calls 7: sys_mmaprp_ink_maprp_trimrp_gutter_colsrp_gutter_rowsrp_rect_ink+1 |
| 305 | func rp_emit(src: *u8, outdir: *u8, rtl: i64) -> i64 called by 2: mainmain calls 9: sys_mmapsys_read_filenx_img_bytes_to_rgbrp_detectrp_ap_strrp_ap_num+3 |