Files
@ 0fd3bebe7462
Branch filter:
Location: OneEye/exp/createsamples.py - annotation
0fd3bebe7462
737 B
text/x-python
export sample cells
0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 0fd3bebe7462 | import sys
sys.path.append("../src")
import os
import json
import PIL.Image
from analyzer.epoint import EPoint
from analyzer.grid import Grid
filepath=sys.argv[1]
with open(filepath,mode="rt") as f:
annotations=json.load(f)
for (filename,data) in annotations.items():
grid=Grid([EPoint(x,y) for (x,y) in data["corners"]])
intersections=grid.intersections
img=PIL.Image.open(os.path.join(os.path.dirname(filepath), filename))
basename=filename.partition(".")[0]
for (r,row) in enumerate(intersections):
for (c,p) in enumerate(row):
(w,h)=map(int,grid.stoneSizeAt(r,c))
x=p.x-w//2
y=p.y-h//2
cut=img.transform((w,h),PIL.Image.EXTENT,(x,y,x+w,y+h))
cut.save("/tmp/stones/{0}-{1}-{2}.jpg".format(basename,r,c))
|