def _toggle_roi(self, checked): if not checked: try: self.imageView.view.removeItem(self.data['roi']) self.data['roi'].sigRegionChangeFinished.disconnect( self._update_images) self.data['roi'] = None except KeyError: pass else: try: image = self.data['image'] except KeyError: return roi = ROI((0, 0), (image.shape[0] // 2, image.shape[1] // 2), movable=False, rotatable=False, resizable=False) roi.addScaleHandle([0, 1], [0.5, 0.5]) roi.addScaleHandle([1, 0], [0.5, 0.5]) roi.addTranslateHandle([0.5, 0.5]) roi.sigRegionChangeFinished.connect(self._update_images) self.data['roi'] = roi self.imageView.view.addItem(roi) self._update_images()
def add_rect_roi(self): x = int(self.data.shape[0]/2) y = int(self.data.shape[1]/2) w = int(self.data.shape[0]/10) h = int(self.data.shape[1]/10) pen, sign = self._get_pen_and_sign() new = ROI([x,y], [w,h], removable=True, pen=pen) new.addScaleHandle([1, 0.5], [0, 0.5]) new.addScaleHandle([0, 0.5], [1, 0.5]) new.addScaleHandle([0.5, 0], [0.5, 1]) new.addScaleHandle([0.5, 1], [0.5, 0]) new.addScaleHandle([0, 1], [1, 0]) new.addScaleHandle([1, 0], [0, 1]) new.addScaleHandle([1, 1], [0, 0]) new.addScaleHandle([0, 0], [1, 1]) new.sigRegionChangeFinished.connect(self.update_mask) new.sigRemoveRequested.connect(self.remove_roi) self._append_roi(new, sign)