-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
67 lines (46 loc) · 2.28 KB
/
test.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##########################################################################
# Tests for DoG Saliency
# Copyright (c) 2020 Ryan Lail, Durham University, UK
##########################################################################
import os
import cv2
import numpy as np
from saliencyDoG import SaliencyDoG
##########################################################################
ORIGINAL_DIR = 'test'+os.sep+'samples'+os.sep
TRUTH_DIR = 'test'+os.sep+'true_saliency_maps'+os.sep
##########################################################################
class TestClass:
def test_one(self):
# default test
test_img = cv2.imread(ORIGINAL_DIR + 'fig_2.png')
test_saliency_mapper = SaliencyDoG()
test_map = test_saliency_mapper.generate_saliency(test_img)
test_map_truth = cv2.imread(TRUTH_DIR + 'fig_2_saliency.png',
0)
assert np.array_equal(cv2.UMat.get(test_map), test_map_truth)
def test_two(self):
# 3 channel test
test_img = cv2.imread(ORIGINAL_DIR + 'fig_2.png')
test_saliency_mapper = SaliencyDoG(ch_3=True)
test_map = test_saliency_mapper.generate_saliency(test_img)
test_map_truth = cv2.imread(TRUTH_DIR + 'fig_2_saliency_3_ch.png',
0)
assert np.array_equal(cv2.UMat.get(test_map), test_map_truth)
def test_three(self):
# low pass filter test
test_img = cv2.imread(ORIGINAL_DIR + 'fig_2.png')
test_saliency_mapper = SaliencyDoG(low_pass_filter=True)
test_map = test_saliency_mapper.generate_saliency(test_img)
test_map_truth = cv2.imread(TRUTH_DIR + 'fig_2_saliency_lp.png',
0)
assert np.array_equal(cv2.UMat.get(test_map), test_map_truth)
def test_four(self):
# multi later map test
test_img = cv2.imread(ORIGINAL_DIR + 'fig_2.png')
test_saliency_mapper = SaliencyDoG(multi_layer_map=True)
test_map = test_saliency_mapper.generate_saliency(test_img)
test_map_truth = cv2.imread(TRUTH_DIR + 'fig_2_saliency_mlm.png',
0)
assert np.array_equal(cv2.UMat.get(test_map), test_map_truth)
##########################################################################