-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask2.py
executable file
·162 lines (123 loc) · 3.92 KB
/
task2.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import sys
from PyQt5 import QtCore, QtWidgets , QtGui
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget , QApplication,QPushButton,QInputDialog,QSpinBox,QFileDialog,QProgressBar,QMessageBox
from PyQt5.QtCore import QSize,pyqtSlot,QTimer,QThread
from PyQt5.QtGui import QIcon, QPixmap
from PIL import Image
import numpy as np
from numpy import array
from PIL.ImageQt import ImageQt
import time
import threading
from scipy.fftpack import ifft
import cv2
#class hiThread(QThread):
#
# def __init__(self,name):
# QThread.__init__(self)
#
#
# def __del__(self):
# self.wait()
#
#
# def stopConverting(self):
# btn = QPushButton("Convert InOut",self)
# btn.setToolTip('This is an example button')
# btn.move(390,200)
# #print('this is the convert in outbutton function')
# btn.show()
# #threading.Thread(target=btn.clicked.connect,args=(self.changeConvertStatus,)).start()
# btn.clicked.connect(self.changeConvertStatus)
#
# def hello(self):
# while 1 :
#
# print('hello ')
# time.sleep(1)
#
# def run(self):
# self.hello()
#
#
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Image Converter")
self.setGeometry(500,500,500,500)
self.spinb = ''
self.fimg = ''
self.pause = 0
self.allowconvert = 0
self.path = 'this is empyt pass'
self.progress = 0
self.layout()
#self.threadClass = ThreadClass()
#self.threadClass.start()
def layout(self):
self.label()
self.home()
self.spinb = self.spinBox()
self.show()
def label(self):
li = QLabel(self)
li.setText('Conversion Speed')
li.setGeometry(145,100,120,20)
#li.move(145,100)
def label1(self):
li1 = QLabel(self)
return li1
def label2(self):
li2 = QLabel(self)
return li2
def home(self):
btn = QPushButton("Select image",self)
btn.setToolTip('This is an example button')
btn.clicked.connect(self.on_click)
btn.move(140,10)
def spinBox(self):
sbox = QSpinBox(self)
sbox.setValue(1)
sbox.move(255,100)
sbox.setMaximum(64)
return sbox
def progressBar(self):
progressBar = QProgressBar(self)
progressBar.setGeometry(5,380,500,20)
progressBar.setValue(0)
return progressBar
@pyqtSlot()
def on_click(self):
name = QFileDialog()
imgPath = name.getOpenFileName(self,'open file','','Image files (*.jpg *.png *.jpeg)')
self.checkImage(imgPath[0])
def checkImage(self,path):
im = Image.open(path)
width, height = im.size
self.path = path
img = cv2.imread(path)
img = Image.fromarray(img)
#print(type(img))
self.showArrayImage(self.label1(),img,10,10)
def showArrayImage(self,label,img,x,y):
qimage = ImageQt(img)
pixmap = QPixmap.fromImage(qimage)
label.setPixmap(pixmap)
label.setGeometry(x,y,128,128)
label.mousePressEvent = self.getPixel
label.show()
def getPixel (self, event):
x = event.pos().x()
y = event.pos().y()
print(x,y)
def conver3dTo2dArray(arr,index):
arr2 = np.array(np.zeros([len(arr),len(arr[0])]))
for i in range(len(arr2)):
for j in range(len(arr2[0])):
arr2[i][j] = arr[i][j][index]
return arr2
def main():
app = QApplication(sys.argv)
window = Window()
sys.exit(app.exec_())
main()