|
2 | 2 | import cv2
|
3 | 3 | import os
|
4 | 4 | import pytest
|
5 |
| -import matplotlib.pyplot as plt |
6 | 5 | import sparse
|
7 |
| -from util import ImagePydataSparseTensorLoader, safeCastPydataTensorToInts, TnsFileDumper |
8 |
| - |
9 |
| - |
10 |
| -# plot_image plots the given original, binned, xor, and sparse xor images |
11 |
| -# for the numpy/image.py. Used for debugging only with the --plot flag |
12 |
| -def plot_image(img, img1, img2, xor_img, sparse_xor_img, t1, t2, window=None): |
13 |
| - f, ax = plt.subplots(2, 3) |
14 |
| - ax[0, 0].imshow(img1, 'gray') |
15 |
| - ax[0, 0].title.set_text("Binned Image 1. t1 = " + str(t1)) |
16 |
| - |
17 |
| - ax[0, 1].imshow(img2, 'gray') |
18 |
| - ax[0, 1].title.set_text("Binned Image 2. t2 = " + str(t2)) |
19 |
| - |
20 |
| - ax[1, 0].imshow(img, 'gray') |
21 |
| - ax[1, 0].title.set_text("Saturdated Image") |
22 |
| - |
23 |
| - ax[1, 1].imshow(xor_img, 'gray') |
24 |
| - ax[1, 1].title.set_text("XOR Image") |
25 |
| - |
26 |
| - ax[1, 2].imshow(sparse_xor_img, 'gray') |
27 |
| - ax[1, 2].title.set_text("Sparse XOR Image") |
28 |
| - |
29 |
| - if window is not None: |
30 |
| - ax[0, 2].imshow(window, 'gray') |
31 |
| - ax[0, 2].title.set_text("Fused Window Image") |
32 |
| - |
33 |
| - f.tight_layout() |
34 |
| - plt.show() |
| 6 | +from util import ImagePydataSparseTensorLoader, safeCastPydataTensorToInts, TnsFileDumper #plot_image |
35 | 7 |
|
| 8 | +# import matplotlib.pyplot as plt |
36 | 9 |
|
37 | 10 | @pytest.mark.parametrize("num", list(range(1, 99)))
|
38 | 11 | @pytest.mark.parametrize("pt1", [0.5])
|
@@ -68,7 +41,7 @@ def dense_bench():
|
68 | 41 | sparse_xor_img = sparse_xor_img.todense()
|
69 | 42 | t1 = round(loader.max[num]*pt1, 2)
|
70 | 43 | t2 = round(loader.max[num]*(pt1 + 0.05), 2)
|
71 |
| - plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2) |
| 44 | + #plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2) |
72 | 45 |
|
73 | 46 | @pytest.mark.parametrize("num", list(range(1, 99)))
|
74 | 47 | @pytest.mark.parametrize("pt1", [0.5])
|
@@ -121,7 +94,7 @@ def dense_bench():
|
121 | 94 | sparse_xor_img = sparse_xor_img.todense()
|
122 | 95 | t1 = round(loader.max[num]*pt1, 2)
|
123 | 96 | t2 = round(loader.max[num]*(pt1 + 0.05), 2)
|
124 |
| - plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2, bin_window) |
| 97 | + #plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2, bin_window) |
125 | 98 |
|
126 | 99 | assert(sparse_xor_img.nnz == np.sum(xor_img != 0))
|
127 | 100 |
|
@@ -190,7 +163,7 @@ def dense_bench():
|
190 | 163 | t1 = round(loader.max[num]*pt1, 2)
|
191 | 164 | t2 = round(loader.max[num]*(pt1 + 0.05), 2)
|
192 | 165 | print(xor_img)
|
193 |
| - plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2) |
| 166 | + #plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2) |
194 | 167 |
|
195 | 168 | assert(sparse_xor_img.nnz == np.sum(xor_img != 0))
|
196 | 169 |
|
@@ -260,7 +233,3 @@ def dense_bench():
|
260 | 233 | print("Sparse xor NNF = ", sparse_xor_img.nnz, "\t", "Dense xor NNF = ", np.sum(xor_img != int(f)))
|
261 | 234 | print("Dense xor NNZ = ", np.sum(xor_img != 0))
|
262 | 235 | assert(sparse_xor_img.nnz == np.sum(xor_img != 1))
|
263 |
| - |
264 |
| -if __name__=="__main__": |
265 |
| - main() |
266 |
| - |
0 commit comments