cp /workspace/scratch/matting.py /workspace/scratch/matting3.py; python - <<'PY'
p='/workspace/scratch/matting.py';s=open(p).read();s=s.replace('B=b\n','''ratio=(a+.002)/(b+.002)
 small=cv2.resize(ratio,(600,400),interpolation=cv2.INTER_AREA)
 sh=np.stack([ndi.percentile_filter(small[:,:,c],15,size=9) for c in range(3)],2)
 sh=cv2.resize(np.minimum(sh,1.0),(2400,1600),interpolation=cv2.INTER_LINEAR)
 B=b*np.clip(sh,.25,1.0)
''');s=s.replace("num=(diff*perp).sum(2)+.015*(diff*v).sum(2)","num=(diff*v).sum(2)").replace("den=(perp*perp).sum(2)+.015*(v*v).sum(2)","den=(v*v).sum(2)");open(p,'w').write(s)
PY
OPENBLAS_NUM_THREADS=1 python /workspace/scratch/matting.py HH-1206