python - <<'PY'
import numpy as np,cv2,json
s='HH-8256';p='/workspace/scratch/finalmasks/'+s+'.png';m=cv2.imread(p,0)>127;m=m.astype('uint8')*255;ox,oy=json.load(open('/workspace/scratch/detailboxes.json'))[s][:2]
curve=[[82,1068],[89,1074],[101,1079],[119,1085],[140,1088],[169,1091],[199,1093],[234,1091],[264,1088],[288,1081],[304,1075],[317,1068]]
pp=curve+[[330,1140],[70,1140]];cv2.fillPoly(m,[np.array(pp,'int32')+[ox,oy]],0)
# Smooth only small notches on the opaque chimney.
r=m[oy+100:oy+507,ox+180:ox+220];m[oy+100:oy+507,ox+180:ox+220]=cv2.morphologyEx(r,cv2.MORPH_CLOSE,np.ones((17,3),np.uint8))
cv2.imwrite(p,cv2.GaussianBlur(m,(3,3),.4))
PY