10
10
# local modules
11
11
12
12
pg .mkQApp ()
13
- pg .setConfigOption ('imageAxisOrder' , 'col -major' )
13
+ pg .setConfigOption ('imageAxisOrder' , 'row -major' )
14
14
15
15
base_path = Path (__file__ ).parent
16
16
file_path = (base_path / "image_analysis_gui.ui" ).resolve ()
@@ -36,8 +36,9 @@ def __init__(self):
36
36
self .imv = pg .ImageView ()
37
37
self .imv .getView ().setAspectLocked (lock = False , ratio = 1 )
38
38
self .imv .getView ().setMouseEnabled (x = True , y = True )
39
- self .imv .getView ().invertY (False )
39
+ # self.imv.getView().invertY(False)
40
40
self .roi = self .imv .roi
41
+
41
42
self .roi .translateSnap = True
42
43
self .roi .scaleSnap = True
43
44
self .update_camera () #initialize camera pixel size
@@ -62,7 +63,7 @@ def load_image(self):
62
63
try :
63
64
file = QtWidgets .QFileDialog .getOpenFileName (self , 'Open file' , os .getcwd ())
64
65
self .original_image = Image .open (file [0 ])
65
- self .original_image = self .original_image .rotate (- 90 , expand = True ) #correct image orientation
66
+ # self.original_image = self.original_image.rotate(-90, expand=True) #correct image orientation
66
67
self .resize_to_scaling_factor (self .original_image )
67
68
except Exception as err :
68
69
print (format (err ))
@@ -73,18 +74,29 @@ def resize_to_scaling_factor(self, image):
73
74
"""
74
75
self .update_camera () #initialize camera pixel size
75
76
self .update_scaling_factor () #initialize scaling_factor
76
- image = image .resize ((round (image .size [0 ]* self .scaling_factor ), round (image .size [1 ]* self .scaling_factor )))
77
+
78
+ if self .ui .pixera_radioButton .isChecked ():
79
+ image = self .original_image
80
+ elif self .ui .spot_radioButton .isChecked ():
81
+ image = self .original_image .resize ((round (image .size [0 ]* self .scaling_factor ), round (image .size [1 ]* self .scaling_factor )))
82
+
77
83
if self .ui .greyscale_checkBox .isChecked ():
78
84
image = image .convert ("L" ) #convert to greyscale
79
- image_array = np .array (image )
80
85
86
+ image_array = np .array (image )
81
87
width = image_array .shape [0 ]
82
88
height = image_array .shape [1 ]
89
+ if self .ui .pixera_radioButton .isChecked ():
90
+ width = width * self .scaling_factor
91
+ height = height * self .scaling_factor
92
+
83
93
try :
84
- x_vals = np .arange (width ) #imv x-axis
94
+ x_vals = np .arange (width )
85
95
self .imv .setImage (image_array , xvals = x_vals )
86
- self .roi .setPos ((0 ,0 ))
87
- self .roi .setSize ([width , self .camera_pixel_size ])
96
+
97
+ roi_height = self .scaling_factor * height
98
+ self .roi .setPos ((0 ,height - roi_height ))
99
+ self .roi .setSize ([width , roi_height ])
88
100
89
101
scale = pg .ScaleBar (size = 1 ,suffix = 'um' )
90
102
scale .setParentItem (self .imv .view )
@@ -151,8 +163,10 @@ def switch_custom_pixel_size(self):
151
163
def update_camera (self ):
152
164
if self .ui .spot_radioButton .isChecked ():
153
165
self .camera_pixel_size = 7.4
166
+ self .ui .greyscale_checkBox .setChecked (False )
154
167
elif self .ui .pixera_radioButton .isChecked ():
155
168
self .camera_pixel_size = 3
169
+ self .ui .greyscale_checkBox .setChecked (True )
156
170
157
171
def close_application (self ):
158
172
choice = QtGui .QMessageBox .question (self , 'EXIT!' ,
0 commit comments