-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_ground_truth.py
More file actions
37 lines (35 loc) · 1.23 KB
/
Copy pathplot_ground_truth.py
File metadata and controls
37 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import matplotlib.pyplot as plt
import glob, os, sys, json, itertools
from distutils.dir_util import mkpath
from os.path import basename
from skimage.io import imread
from distutils.dir_util import mkpath
from itertools import cycle
base_dir = sys.argv[1]
if len(sys.argv) > 2:
file_pattern = sys.argv[2]
else:
file_pattern = '*'
filenames = glob.glob('images/%s/%s.png' % (base_dir, file_pattern))
for filename in filenames:
colors = cycle(['blue', 'red', 'yellow', 'green'])
ground_truth_path = 'ground-truth/%s' % base_dir
base_filename = basename(os.path.splitext(filename)[0])
with open("%s/%s.json" % (ground_truth_path, base_filename)) as f:
ground_truth = json.loads(f.read())
image = imread(filename)
fig = plt.figure()
plt.imshow(image)
plt.axis('off')
ground_truth_image_path = "images/%s/ground-truth" % base_dir
mkpath(ground_truth_image_path)
for line in ground_truth['lines']:
plt.plot(
[line['xLeft'], line['xRight']],
[line['yTop'], line['yBottom']],
'.',
color=colors.next(),
markersize=1
)
plt.savefig("%s/%s.eps" % (ground_truth_image_path, base_filename), format='eps', dpi=400)
plt.clf()