@@ -1333,14 +1333,9 @@ def preallocate_matrices(self):
13331333 dtype = np .uint16 ,
13341334 )
13351335
1336- def get_mip_image (self , channel_idx ):
1336+ def get_mip_image (self ):
13371337 """Get MIP image according to perspective and channel id
13381338
1339- Parameters
1340- ----------
1341- channel_idx : int
1342- channel id
1343-
13441339 Returns
13451340 -------
13461341 image : numpy.ndarray
@@ -1350,6 +1345,7 @@ def get_mip_image(self, channel_idx):
13501345 return None
13511346
13521347 display_mode = self .render_widgets ["perspective" ].get ()
1348+ channel_idx = int (self .render_widgets ["channel" ].get ()[2 :]) - 1
13531349 if display_mode == "XY" :
13541350 image = self .xy_mip [channel_idx ]
13551351 elif display_mode == "ZY" :
@@ -1358,6 +1354,8 @@ def get_mip_image(self, channel_idx):
13581354 image = self .zx_mip [channel_idx ]
13591355
13601356 image = self .flip_image (image )
1357+ # map the image to canvas size()
1358+ image = self .down_sample_image (image , True )
13611359 return image
13621360
13631361 def initialize_non_live_display (self , microscope_state , camera_parameters ):
@@ -1402,17 +1400,34 @@ def try_to_display_image(self, image):
14021400 self .zx_mip [channel_idx , slice_idx ], np .max (image , axis = 1 )
14031401 )
14041402
1405- self .image = self .get_mip_image (channel_idx )
1403+ super ().try_to_display_image (image )
1404+
1405+ def display_image (self , image ):
1406+ """Display an image using the LUT specified in the View.
1407+
1408+ If Autoscale is selected, automatically calculates
1409+ the min and max values for the data.
1410+
1411+ If Autoscale is not selected, takes the user values
1412+ as specified in the min and max counts.
1413+
1414+ Parameters
1415+ ----------
1416+ image : numpy.ndarray
1417+ Image data.
1418+ """
1419+ self .image = self .get_mip_image ()
14061420 self .process_image ()
1421+ with self .is_displaying_image as is_displaying_image :
1422+ is_displaying_image .value = False
14071423
14081424 def display_mip_image (self , * args ):
14091425 """Display MIP image in non-live view"""
14101426 if self .perspective != self .render_widgets ["perspective" ].get ():
14111427 self .update_perspective ()
14121428 if self .mode != "stop" :
14131429 return
1414- channel_idx = int (self .render_widgets ["channel" ].get ()[2 :]) - 1
1415- self .image = self .get_mip_image (channel_idx )
1430+ self .image = self .get_mip_image ()
14161431 if self .image is not None :
14171432 self .process_image ()
14181433
@@ -1432,6 +1447,16 @@ def update_perspective(self, *args, display=False):
14321447 self .update_canvas_size ()
14331448 self .reset_display (False )
14341449
1450+ def down_sample_image (self , image , reset_original = False ):
1451+ """Down-sample the data for image display according to widget size."""
1452+ sx , sy = self .canvas_width , self .canvas_height
1453+ down_sampled_image = cv2 .resize (image , (sx , sy ))
1454+ if reset_original :
1455+ self .original_image_width = self .canvas_width
1456+ self .original_image_height = self .canvas_height
1457+ self .canvas_width_scale = 1
1458+ self .canvas_height_scale = 1
1459+ return down_sampled_image
14351460
14361461class SpooledImageLoader :
14371462 """A class to lazily load images from disk using a spooled temporary file."""
0 commit comments