run_pixel_nested_frame_049.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_pixel_nested_frame_049.py Source: /Voynich/Voynich_PIXEL_BOUNDARY_LOCALIZATION_050_reproducibility.zip!/run_pixel_nested_frame_049 .py SHA-256: 58696c9055dc97852adbb399ae89807b030c85ee4113f04533fc3b8fc7983fff !/usr/bin/env python3 """PIXEL-NESTED-FRAME-049: physical image test of internal R->L handoffs.""" from pathlib import Path from collections import Counter,defaultdict import csv,hashlib,json,math,re import fitz,numpy as np,pandas as pd from scipy import ndimage from sklearn.feature_extraction import DictVectorizer from sklearn.linear_model import LogisticRegression from sklearn.metrics import log_loss,balanced_accuracy_score import run_citation_dictionary_027 as c27 ROOT=Path(__file__).resolve().parent;OUT=ROOT/'pixel_nested_frame_049';OUT.mkdir(exist_ok=True);PDF=ROOT /'library_scan/Voynich_Manuscript.pdf';SRC=ROOT/'crosswalk002_inputs/Voynich_Line_Local_Reproducibility_ 2026-08-22/data/ZL.txt';BOX=ROOT/'glyph_crop_atlas_001/aligned_token_boxes.csv';SEED=20260830;REPS=200;M ISSING={12,*range(59,65),74,91,92,97,98,109,110};TOK=re.compile(r'[A-Z][0-9a-z]');LOC=re.compile(r'^<([^ >.]+)\.([^,>]+),[^>]*>\s*(.*)$');PAGE=re.compile(r'^<([^>.]+)>\s*]*)>');META=re.compile(r'\$([A-Z] )=([^\s>]+)') def fold(f):return int(hashlib.sha256(('pixel-nested-frame-049|'+f).encode()).hexdigest()[:8],16)%5 def sec(f): n=int(re.search(r'\d+',f).group());return 'Herbal' if n<=66 else 'Astro' if n<=73 else 'Bio' if 75<=n<=84 else 'Pharma' if 87<=n<=102 else 'Recipes' if 103<=n<=116 else 'Other' def pages(): s=[] for n in range(1,117): if n not in MISSING:s += [f'f{n}r',f'f{n}v'] return {f:i+2 for i,f in enumerate(s)} def parse(): out={};meta={};pending=None for raw in SRC.read_text(errors='ignore').splitlines(): pm=PAGE.match(raw) if pm:meta[pm.group(1)]=dict(META.findall(pm.group(2)));continue m=LOC.match(raw) if m: pending=m.groups() if pending[2].strip():fol,line,txt=pending;pending=None else:continue elif pending and raw and not raw.startswith(('<','#')):fol,line,txt=pending;txt+=' '+raw;pending=None else:continue clean=re.sub(r'<[^>]*>','',txt).replace('[','').replace(']','').replace(':','');z=[] for w in re.split(r'[.,\s]+',clean): a=TOK.findall(w) if len(a)>=3:z.append(a) if z and line.isdigit():out[(fol,int(line))]=z return out,meta def otsu(a): h=np.bincount(a.ravel(),minlength=256).astype(float);p=h/h.sum();w=np.cumsum(p);mu=np.cumsum(p*np.arang e(256));mt=mu[-1];return int(np.argmax((mt*w-mu)**2/(w*(1-w)+1e-12))) def maxrun(q): best=cur=0 for x in q: cur=cur+1 if x else 0;best=max(best,cur) return best def pixfeat(gray,box): h,w=gray.shape;sx=w/600;sy=h/837;x0=max(0,int((box.x-2)*sx));x1=min(w,int((box.x+box.w+2)*sx));y0=max(0 ,int((box.y-2)*sy));y1=min(h,int((box.y+box.h+2)*sy));c=gray[y0:y1,x0:x1] if c.size<30:return None ink=c