cat > /workspace/scratch/edits_more.py <<'PY'
import json,numpy as np
p='/workspace/scratch/edits.json';e=json.load(open(p))
def ellipse(cx,cy,rx,ry,n=64):return [[round(cx+rx*np.cos(t)),round(cy+ry*np.sin(t))] for t in np.linspace(0,2*np.pi,n,endpoint=False)]
e['HH-6618']={'fg':[ellipse(405,475,273,67)],'bottom':993}
e['HH-6672']={'fg':[ellipse(333,647,158,41)],'bg':[[[284,509],[316,516],[320,541],[301,535]],[[340,511],[353,511],[348,535],[340,537]]],'bottom':1085}
e['HH-3360']={'bg':[[[428,581],[470,581],[470,740],[427,740]],[[206,442],[223,449],[226,468],[206,468]],[[425,437],[443,442],[444,459],[447,467],[451,476],[459,481],[450,495],[430,489]]],'bottom':1115}
e['HH-8205']['bg']=[[[499,458],[536,458],[536,535],[496,535]],[[472,553],[536,553],[536,606],[469,606]],[[509,631],[536,631],[536,700],[519,698],[516,681],[510,654]]]
e['HH-3315']={'fg':[
[[140,697],[234,697],[228,713],[215,725],[201,732],[178,731],[156,718]],
[[184,676],[322,676],[316,690],[289,704],[278,722],[258,730],[240,726],[223,710],[215,704],[184,694]],
[[624,678],[755,678],[750,694],[727,706],[716,722],[693,733],[671,727],[655,709],[632,702]],
[[835,699],[924,699],[918,718],[899,731],[876,734],[854,721]]
], 'lines':[
[[[493,403],[486,464],[469,521],[448,568],[429,611],[405,653],[372,691],[336,718],[301,739],[275,747]],2],
[[[524,403],[532,465],[547,522],[567,570],[591,615],[620,660],[656,699],[693,724],[727,742]],2],
[[[181,765],[181,807],[181,858],[181,905]],2],[[[237,765],[237,816],[237,867],[237,910]],2],[[[439,796],[439,841],[439,894]],2],[[[609,777],[609,818],[609,867],[609,898]],2],[[[754,778],[754,824],[754,867],[754,913]],2],[[[858,779],[858,822],[858,870],[858,913]],2]
]}
e['HH-8248']={'replace':[[55,366],[232,357],[238,291],[250,124],[254,78],[273,64],[719,78],[738,104],[739,360],[762,366],[812,375],[812,411],[791,413],[785,1062],[752,1063],[752,832],[728,832],[728,756],[277,747],[279,815],[275,820],[250,820],[241,744],[113,742],[109,1033],[103,1040],[69,1037],[69,403],[55,402]],'band':7,'bg':[[[117,400],[208,390],[212,468],[188,474],[162,487],[138,510],[116,533]] ]}
e['HH-8285']={'band':5,'solid_small':30,'fg':[
[[790,410],[831,408],[855,450],[868,503],[883,552],[890,583],[915,645],[945,740],[966,804],[984,857],[1008,938],[1036,1046],[1027,1054],[1008,1053],[1000,1046],[974,978],[958,935],[945,897],[927,845],[908,786],[886,732],[863,666],[842,612],[825,560],[806,505],[791,458]]
], 'bg':[
[[241,438],[349,444],[337,679],[174,688],[199,611]],
[[430,451],[611,448],[637,648],[411,674]],
[[674,442],[787,423],[877,678],[694,670],[683,621]],
[[161,722],[334,704],[320,829],[307,911],[87,914],[105,859],[130,787]],
[[400,713],[572,824],[378,859]],[[441,695],[642,673],[667,814],[631,817]],
[[694,690],[878,690],[910,794],[696,814]]
]}
e['HH-7101']={'replace':[[126,136],[318,128],[503,119],[696,121],[904,128],[1100,139],[1205,161],[1264,212],[1310,293],[1316,400],[1322,539],[1320,707],[1320,825],[1318,953],[1297,1020],[1254,1056],[1236,1136],[1121,1142],[1104,1111],[1103,1084],[900,1087],[701,1095],[499,1095],[278,1081],[250,1080],[235,1161],[114,1162],[83,1084],[48,1044],[9,993],[-10,873],[-11,591],[-1,389],[27,282],[65,237],[85,184]],'band':15}
e['HH-7158']={'bg':[[[864,953],[928,941],[957,964],[993,1030],[1037,1089],[1042,1125],[849,1125]]],'band':5}
# force broad core of the ball, without losing the soft outer mass
b=json.load(open('/workspace/scratch/detailboxes.json'))['HH-2342'];poly=json.load(open('/workspace/scratch/softpolys.json'))['HH-2342']
e['HH-2342']={'replace':[[round(x*2-b[0]),round(y*2-b[1])] for x,y in poly],'band':15}
json.dump(e,open(p,'w'),indent=2)
PY
python /workspace/scratch/edits_more.py
python - <<'PY'
p='/workspace/scratch/applyedits.py';s=open(p).read();s=s.replace("m=cv2.imread('/workspace/scratch/hard/'+s+'.png',0)","m=cv2.imread('/workspace/scratch/hard/'+s+'.png',0)\n if m is None:m=cv2.imread('/workspace/scratch/auto/'+s+'.png',0)")
s=s.replace("if 'bottom' in e:","if 'replace' in e:\n  m[:]=0;cv2.fillPoly(m,[np.array(e['replace'],dtype='int32')+[x,y]],255)\n for line,width in e.get('lines',[]):cv2.polylines(m,[np.array(line,dtype='int32')+[x,y]],False,255,width)\n if 'bottom' in e:")
s=s.replace('gc[di>3]=1;gc[do>3]=0',"gc[di>e.get('band',3)]=1;gc[do>e.get('band',3)]=0")
open(p,'w').write(s)
PY
OPENBLAS_NUM_THREADS=1 python /workspace/scratch/applyedits.py HH-6618 HH-6672 HH-3360 HH-8205 HH-3315 HH-8248 HH-8285 HH-7101 HH-7158 HH-2342