-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.py
46 lines (32 loc) · 1002 Bytes
/
validate.py
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
38
39
40
41
42
43
44
45
46
from skimage.color import gray2rgb
from skimage.io import imread, imsave
from os import listdir, mkdir
from os.path import isfile, join, exists
from skimage.util import compare_images
import numpy as np
import argparse
source = 'source_images'
answer = 'stitched_images'
def _parseArgs():
parser = argparse.ArgumentParser()
parser.add_argument('--file', type=str)
args = parser.parse_args()
return args.file
def compare(file):
sImg = gray2rgb(imread(source + '/' + file))
aImg = imread(answer + '/' + file)
diff = compare_images(sImg, aImg, method='diff')
if np.sum(diff) < 1e-7:
print('Result is correct')
else:
print('See diff file for difference')
imsave('diff.png', diff)
filename = _parseArgs()
if filename:
compare(filename)
else:
files = [f for f in listdir(source) if isfile(join(source, f))]
for i in range(len(files)):
file = files[i]
print('\n\nCMP\t', i, '\t', file)
compare(file)