-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplotMat.py
33 lines (29 loc) · 1 KB
/
plotMat.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
import os
import glob
import errno
import numpy as np
import matplotlib.pyplot as plt
def createdir(dir):
if not os.path.exists(dir):
try:
os.makedirs(dir)
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
def csvtoarr(src):
return np.nan_to_num(np.genfromtxt(src, delimiter=',', skip_header=0, skip_footer=0))
def genimage(src, outpath):
createdir(outpath)
filename = os.path.basename(src).replace('.bmp','').replace('csv','png')
img = csvtoarr(src)
cmap = 'jet' if "hough" in filename else 'gray'
plt.imsave(fname=outpath+'/'+filename, arr=img, vmin=np.min(img), vmax=np.max(img), format='png', cmap=cmap)
#plt.imshow(img, cmap=cmap, vmin=np.min(img), vmax=np.max(img), interpolation='none')
#plt.title(filename)
#plt.colorbar()
#plt.show()
return img
if __name__ == "__main__":
csvs = glob.glob('examples/*.csv')
for csv in csvs:
genimage(csv, 'generated/')