# decryption_complete: false # source: /Voynich/Voynich_PIXEL_BOUNDARY_LOCALIZATION_050_reproducibility.zip!/run_pixel_boundary_localiz # stated_sha256: 5e8a8eeefee44b21e68bc6cfde101eb7c42768f4c324b6dc7edc525dfe6272f2 # matches_stated_sha256: false # pdf_pages: 945-946 # note: The stated SHA-256 is the digest printed in the PDF. # The PDF page extract follows the form feed. decryption_complete stays false. run_pixel_boundary_localization_050.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_pixel_boundary_localization_050.py Source: /Voynich/Voynich_PIXEL_BOUNDARY_LOCALIZATION_050_reproducibility.zip!/run_pixel_boundary_localiz ation_050.py SHA-256: 5e8a8eeefee44b21e68bc6cfde101eb7c42768f4c324b6dc7edc525dfe6272f2 !/usr/bin/env python3 """PIXEL-BOUNDARY-LOCALIZATION-050: within-token physical localization of R->L atom boundaries.""" from pathlib import Path from collections import defaultdict import hashlib,json,math,re import fitz,numpy as np,pandas as pd from scipy import ndimage import run_pixel_nested_frame_049 as p49 import run_citation_dictionary_027 as c27 ROOT=Path(__file__).resolve().parent; OUT=ROOT/'pixel_boundary_localization_050'; OUT.mkdir(exist_ok=True) PDF=p49.PDF; BOX=p49.BOX; SEED=20260830; REPS=1000 def crop_profile(gray,b): h,w=gray.shape;sx=w/600;sy=h/837 x0=max(0,int((b.x-2)*sx));x1=min(w,int((b.x+b.w+2)*sx));y0=max(0,int((b.y-2)*sy));y1=min(h,int((b.y+b.h +2)*sy));c=gray[y0:y1,x0:x1] if c.size<30:return None ink=c0 else c r=col[min(w,x+center+1):min(w,x+center+1+should)].mean() if x+center+1best:best=float(s);bestx=x return best,float(bestx/w),float(nom/w) def main(): lines,meta=p49.parse();boxes=pd.read_csv(BOX);doc=fitz.open(PDF);pm=p49.pages();by=defaultdict(list) for r in boxes.itertuples():by[r.folio].append(r) rows=[];invalid=0;tokens=0 for fol,bb in by.items(): if fol not in pm:continue pix=doc[pm[fol]].get_pixmap(matrix=fitz.Matrix(4,4),colorspace=fitz.csGRAY,alpha=False);gray=np.frombu ffer(pix.samples,dtype=np.uint8).reshape(pix.height,pix.width) for b in bb: z=lines.get((fol,int(b.line))) if z is None or int(b.index)>=len(z):continue a=z[int(b.index)];eligible=list(range(1,len(a)-2));pred=[i for i in eligible if a[i] in c27.R and a[i+1] in c27.L] if not pred or len(eligible)==len(pred):continue col=crop_profile(gray,b) if col is None:invalid+=1;continue tid=f'{fol}:{int(b.line)}:{int(b.index)}';tokens+=1 for i in eligible: score,x,nom=boundary_score(col,i+1,len(a));rows.append({'token_id':tid,'folio':fol,'line':int(b.line ),'index':int(b.index),'hand':meta.get(fol,{}).get('H','?'),'currier':meta.get(fol,{}).get('L','?'),'sec tion':p49.sec(fol),'surface':' '.join(a),'atom_count':len(a),'boundary_after_index':i,'left_atom':a[i],' right_atom':a[i+1],'predicted_rl':int(i in pred),'valley_score':score,'localized_x':x,'nominal_x':nom}) d=pd.DataFrame(rows);d.to_csv(OUT/'boundary_events.csv',index=False) def dif(g,lab='predicted_rl'): run_pixel_boundary_localization_050.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2 return float(g[g[lab]==1].valley_score.mean()-g[g[lab]==0].valley_score.mean()) td=d.groupby('token_id').apply(dif,include_groups=False).rename('within_token_difference').reset_index( );keys=d[['token_id','folio','hand','currier','section']].drop_duplicates();td=td.merge(keys,on='token_i d');td.to_csv(OUT/'token_differences.csv',index=False) folds=[] for k in range(5): q=td[td.folio.map(p49.fold)==k];folds.append({'fold':k,'tokens':len(q),'folios':q.folio.nunique(),'mea n_difference':float(q.within_token_difference.mean()),'positive_token_share':float((q.within_token_diffe rence>0).mean())}) fd=pd.DataFrame(folds);fd.to_csv(OUT/'folio_heldout_folds.csv',index=False);obs=float(td.within_token_d ifference.mean()) groups=[(g.valley_score.to_numpy(),int(g.predicted_rl.sum())) for _,g in d.groupby('token_id')];rng=np.random.default_rng(SEED);null=[] for rep in range(REPS): vals=[] for scores,n in groups: ix=rng.choice(len(scores),n,replace=False);chosen=scores[ix];mask=np.ones(len(scores),bool);mask[ix]= False;vals.append(float(chosen.mean()-scores[mask].mean())) null.append(float(np.mean(vals))) pv=float((1+sum(x>=obs for x in null))/(REPS+1));positive=int((fd.mean_difference>0).sum());passed=bool (obs>0 and positive>=4 and pv<=.05) summary={'test':'PIXEL-BOUNDARY-LOCALIZATION-050','tokens':tokens,'boundary_events':len(d),'folios':d.f olio.nunique(),'invalid_crops_excluded':invalid,'mean_within_token_valley_difference':obs,'positive_fold s':positive,'within_token_permutation_p':pv,'null_mean':float(np.mean(null)),'pass':passed,'rule_count': 6,'boundary':'Proportional narrow-window atom-boundary localization; no ground-truth atom-to-pixel alignment, plaintext, or semantics.'} (OUT/'summary.json').write_text(json.dumps(summary,indent=2));pd.DataFrame({'replicate':range(REPS),'nu ll_mean_difference':null}).to_csv(OUT/'within_token_null.csv',index=False) report=['# PIXEL-BOUNDARY-LOCALIZATION-050','',('**PASS — LOCAL PHYSICAL SEPARATION DETECTED**' if passed else '**FAIL — LOCAL PHYSICAL SEPARATION NOT DETECTED**'),'','Every eligible atom boundary inside each positive token was projected into the physical manuscript crop. Each received the same narrow proportional search window. Predicted internal right-edge to left-edge transitions were compared with all other eligible boundaries inside the identical token. The null reassigned the same number of predicted boundaries within each token.','',f'- Tokens: {tokens:,}; boundary events: {len(d):,}; folios: {d.folio.nunique()}',f'- Mean within-token valley difference: {obs:+.6f}',f'- Positive folio folds: {positive}/5',f'- Within-token permutation p: {pv:.6f}',f'- Invalid crops excluded: {invalid:,}','','## Boundary','','The atlas supplies token boxes, not verified atom coordinates. This is a constrained localization test, not direct glyph segmentation. A failure rejects this proportional physical prediction but cannot prove that no differently aligned micro-stroke boundary exists.','','## Rule audit','',('EDGE HANDOFF gains localized pixel support; no new rule is added and six remain.' if passed else 'No rule change. EDGE HANDOFF remains transcription-supported; six rules remain.')] (OUT/'report.md').write_text('\n'.join(report)+'\n');pd.DataFrame([{'test':'PIXEL-BOUNDARY-LOCALIZATION -050','rule':'EDGE HANDOFF','status':'STRENGTHENED' if passed else 'UNCHANGED','evidence':f'difference={obs:+.6f}; folds={positive}/5; p={pv:.6f}','live_rule_count':6}]).to_csv(OUT/'rule_recovery_audit.csv',index=False) files=sorted(x for x in OUT.iterdir() if x.is_file() and x.name!='SHA256SUMS.txt');(OUT/'SHA256SUMS.txt ').write_text('\n'.join(f'{hashlib.sha256(x.read_bytes()).hexdigest()} {x.name}' for x in files)+'\n');print(json.dumps(summary,indent=2)) if __name__=='__main__':main()