run_glyph_microfeature_audit_026.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_glyph_microfeature_audit_026.py Source: /Voynich/Voynich_GLYPH_MICROFEATURE_AUDIT_026_reproducibility.zip!/run_glyph_microfeature_audit_ 026.py SHA-256: 08c3d74cf4f23c1c0622e327457cf4f49dc62eb664b03f6c0d164db2a1a4cae4 !/usr/bin/env python3 """GLYPH-MICROFEATURE-AUDIT-026: skeleton topology with folio calibration.""" import csv,hashlib,json,math,re from collections import defaultdict from pathlib import Path import fitz,numpy as np,pandas as pd from PIL import Image from scipy import ndimage,sparse from sklearn.feature_extraction import DictVectorizer from sklearn.linear_model import SGDClassifier from sklearn.metrics import accuracy_score,log_loss from sklearn.preprocessing import StandardScaler ROOT=Path(__file__).resolve().parent;PDF=ROOT/'library_scan/Voynich_Manuscript.pdf';BOXCSV=ROOT/'glyph_c rop_atlas_001/aligned_token_boxes.csv';STA=ROOT/'crosswalk002_inputs/Voynich_Line_Local_Reproducibility_ 2026-08-22/data';OUT=ROOT/'glyph_microfeature_audit_026';OUT.mkdir(exist_ok=True) SEED=20260830;REPS=200;MISSING={12,*range(59,65),74,91,92,97,98,109,110};TOK_RE=re.compile(r'[A-Z][0-9a- z]');LOC_RE=re.compile(r'^<([^>.]+)\.([^,>]+),[^>]*>\s*(.*)$') def fold(f):return int(hashlib.sha256(('glyph-micro-026|'+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(): sides=[] for n in range(1,117): if n not in MISSING:sides += [f'f{n}r',f'f{n}v'] return {f:i+2 for i,f in enumerate(sides)} 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 skeleton(b): b=b.copy();s=np.zeros_like(b);st=np.ones((3,3),bool) for _ in range(20): if not b.any():break er=ndimage.binary_erosion(b,structure=st);op=ndimage.binary_dilation(er,structure=st);s|=b&~op;b=er return s def trace_turn(s,y,x,steps=8): path=[(y,x)];prev=None for _ in range(steps): cy,cx=path[-1];cand=[] for yy in range(max(0,cy-1),min(s.shape[0],cy+2)): for xx in range(max(0,cx-1),min(s.shape[1],cx+2)): if s[yy,xx] and (yy,xx)!=(cy,cx) and (yy,xx)!=prev and (yy,xx) not in path:cand.append((yy,xx)) if not cand:break nxt=min(cand,key=lambda q:(q[0]-cy)**2+(q[1]-cx)**2);prev=(cy,cx);path.append(nxt) if len(path)<3:return 0.,0. v=np.diff(np.array(path,float),axis=0);ang=np.unwrap(np.arctan2(v[:,0],v[:,1]));return float((ang[-1]-ang[0])/np.pi),float(ang[0]/np.pi) def micro(a,r): h,w=a.shape;sx=w/600;sy=h/837;x0=max(0,int((r.x-3)*sx));y0=max(0,int((r.y-3)*sy));x1=min(w,int((r.x+r.w +3)*sx));y1=min(h,int((r.y+r.h+3)*sy));c=a[y0:y1,x0:x1] if c.size<20:return None ink=c0;s=skeleton(b) nb=ndimage.convolve(s.astype(int),np.ones((3,3),int),mode='constant')-s;ends=np.argwhere(s&(nb==1));bra nches=np.argwhere(s&(nb>=3));lab,nc=ndimage.label(b);filled=ndimage.binary_fill_holes(b);holes=ndimage.l abel(filled&~b)[1]