@@ -193,16 +193,20 @@ def _record_dark(self, assembled):
193193 def _update_image_mask (self , image_shape ):
194194 image_mask = self ._mask_sub .update (self ._image_mask , image_shape )
195195 if image_mask is not None and image_mask .shape != image_shape :
196- # This could only happen when the mask is loaded from the files
197- # and the image shapes in the ImageTool is different from the
198- # shape of the live images.
199- # The original image mask remains the same.
200- raise ImageProcessingError (
201- f"[Image processor] The shape of the image mask "
202- f"{ image_mask .shape } is different from the shape of the image "
203- f"{ image_shape } !" )
196+ if np .sum (image_mask ) == 0 :
197+ # reset the empty image mask automatically
198+ image_mask = None
199+ else :
200+ # This could only happen when the mask is loaded from the files
201+ # and the image shapes in the ImageTool is different from the
202+ # shape of the live images.
203+ # The original image mask remains the same.
204+ raise ImageProcessingError (
205+ f"[Image processor] The shape of the image mask "
206+ f"{ image_mask .shape } is different from the shape of the image "
207+ f"{ image_shape } !" )
204208
205- elif image_mask is None :
209+ if image_mask is None :
206210 image_mask = np .zeros (image_shape , dtype = np .bool )
207211
208212 self ._image_mask = image_mask
0 commit comments