-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeneral_Scripts.py
108 lines (84 loc) · 2.42 KB
/
General_Scripts.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import cv2
import numpy as np
import os
Sharpen3x3 = np.array([[0, -1, 0],
[-1, 5, -1],
[0, -1, 0]])
Sharpen3x3 = Sharpen3x3.reshape((3, 3))
def interactiveImread(flags=None):
path = os.getcwd()
path = path.replace(path[2], '/')
temp = path.split('/')
while temp[len(temp) - 1] != 'Hilbert-Huang-Transform-Super-Resolution':
temp.pop()
newPath = ''
for t in temp:
newPath += t + '/'
os.chdir(newPath)
newPath += 'DATA/'
lis = os.listdir(newPath)
name = ''
spot = 0
while True:
print("\n \n \n")
print(str(spot + 1) + ' of ' + str(len(lis)))
if spot >= len(lis):
lis = os.listdir(newPath)
spot = 0
name = ''
print("Error 1")
continue
if len(lis) == 0:
lis = os.listdir(newPath)
name = ''
spot = 0
print("Error 2")
continue
print("Standing on: " + lis[spot])
print("\n ***********\nSelect current: esc\nForward: ++\nBackward: --\n ********** \n")
inp = input("Search: ")
if inp == 'esc':
break
elif inp == '++':
spot += 1
continue
elif inp == '--':
spot -= 1
continue
name += inp
lis = list(filter(lambda x: name in x, lis))
spot = 0
newPath = 'DATA/' + lis[spot]
temp = cv2.imread(newPath, flags)
os.chdir(path)
return temp
def imread(fname, flags=None):
path = os.getcwd()
path = path.replace(path[2], '/')
temp = path.split('/')
while temp[len(temp) - 1] != 'Hilbert-Huang-Transform-Super-Resolution':
temp.pop()
newPath = ''
for t in temp:
newPath += t + '/'
os.chdir(newPath)
temp = cv2.imread('DATA/' + fname, flags)
os.chdir(path)
return temp
def get_all_reconstructed(flags=None):
path = os.getcwd()
path = path.replace(path[2], '/')
temp = path.split('/')
while temp[len(temp) - 1] != 'Hilbert-Huang-Transform-Super-Resolution':
temp.pop()
newPath = ''
for t in temp:
newPath += t + '/'
os.chdir(newPath)
newPath += 'Edited Data'
pics = []
lis = os.listdir(newPath)
for imfs in lis:
pics.append(cv2.imread('Edited Data/' + imfs + '/ReConstructed.jpg', flags=flags).copy())
os.chdir(path)
return pics