def draw_splash(self): print('[back] draw_splash()') img = imread('_frontend/splash.png') fig = df2.figure() print(fig) print(fig is self.win.plotWidget.figure) df2.imshow(img) df2.update()
def _plotarrow(x, y, dx, dy, color=df2.BLUE, label=''): ax = df2.gca() arrowargs = dict(head_width=.5, length_includes_head=True, label='') arrow = df2.FancyArrow(x, y, dx, dy, **arrowargs) arrow.set_edgecolor(color) arrow.set_facecolor(color) ax.add_patch(arrow) df2.update()
def segment(img_path, roi): img = cv2.imread(img_path) # Grab cut parametrs (w, h) = img.shape[:2] [rx, ry, rw, rh] = roi expand = 10 rect = (rx - expand, rw + expand, ry - expand, rh + expand) mask_input = np.zeros((w, h), dtype=np.uint8) bg_model = np.zeros((1, 13 * 5)) fg_model = np.zeros((1, 13 * 5)) num_iters = 5 # Make mask specify the ROI mask_input[ry:(ry + rh), rx:(rx + rw)] = cv2.GC_PR_FGD grabcut_mode = cv2.GC_INIT_WITH_MASK # Do grab cut (mask, bg_model, fg_model) = cv2.grabCut(img, mask_input, rect, bg_model, fg_model, num_iters, mode=grabcut_mode) # Make the segmented chip # Normalize mask mask = np.array(mask, np.float64) mask[mask == cv2.GC_BGD] = 0 #.1 mask[mask == cv2.GC_PR_BGD] = 0 #.25 mask[mask == cv2.GC_PR_FGD] = 1 #.75 mask[mask == cv2.GC_FGD] = 1 # Clean the mask element = cv2.getStructuringElement(cv2.MORPH_CROSS, (10, 10)) tmp_ = mask tmp_ = cv2.erode(tmp_, element) tmp_ = cv2.dilate(tmp_, element) tmp_ = cv2.dilate(tmp_, element) tmp_ = cv2.dilate(tmp_, element) df2.imshow(tmp_) df2.update() mask = tmp_ # Reshape chip_mask to NxMx3 color_mask = np.tile(chip_mask.reshape(tuple(list(chip_mask.shape) + [1])), (1, 1, 3)) seg_chip = np.array(chip, dtype=np.float) * color_mask seg_chip = np.array(np.round(seg_chip), dtype=np.uint8) return seg_chip
def segment(img_path, roi): img = cv2.imread(img_path) # Grab cut parametrs (w, h) = img.shape[:2] [rx, ry, rw, rh] = roi expand = 10 rect = (rx-expand, rw+expand, ry-expand, rh+expand) mask_input = np.zeros((w,h), dtype=np.uint8) bg_model = np.zeros((1, 13 * 5)) fg_model = np.zeros((1, 13 * 5)) num_iters = 5 # Make mask specify the ROI mask_input[ry:(ry+rh), rx:(rx+rw)] = cv2.GC_PR_FGD grabcut_mode = cv2.GC_INIT_WITH_MASK # Do grab cut (mask, bg_model, fg_model) = cv2.grabCut(img, mask_input, rect, bg_model, fg_model, num_iters, mode=grabcut_mode) # Make the segmented chip # Normalize mask mask = np.array(mask, np.float64) mask[mask == cv2.GC_BGD] = 0#.1 mask[mask == cv2.GC_PR_BGD] = 0#.25 mask[mask == cv2.GC_PR_FGD] = 1#.75 mask[mask == cv2.GC_FGD] = 1 # Clean the mask element = cv2.getStructuringElement(cv2.MORPH_CROSS,(10,10)) tmp_ = mask tmp_ = cv2.erode(tmp_, element) tmp_ = cv2.dilate(tmp_, element) tmp_ = cv2.dilate(tmp_, element) tmp_ = cv2.dilate(tmp_, element) df2.imshow(tmp_); df2.update() mask = tmp_ # Reshape chip_mask to NxMx3 color_mask = np.tile(chip_mask.reshape(tuple(list(chip_mask.shape)+[1])), (1, 1, 3)) seg_chip = np.array(chip, dtype=np.float) * color_mask seg_chip = np.array(np.round(seg_chip), dtype=np.uint8) return seg_chip
#kpts, desc = filter_kpts_scale(kpts, desc) df2.figure(1, doclf=True) df2.DARKEN = .5 #---- df2.imshow(rchip, plotnum=(2,3,1), title='0 before (inverse square root)') draw_kpts3(kpts0.copy(),0) #---- df2.imshow(rchip, plotnum=(2,3,2), title='1 just inverse') draw_kpts3(kpts1.copy(),1) #---- df2.imshow(rchip, plotnum=(2,3,3), title='2 identity') draw_kpts3(kpts1.copy(), 2) df2.update() #---- df2.imshow(rchip, plotnum=(2,3,4), title='3 identity') draw_kpts3(kpts1.copy(), 3) df2.update() #---- df2.imshow(rchip, plotnum=(2,3,5), title='inv sqrtm 4') draw_kpts3(kpts1.copy(), 4) df2.update() #---- df2.imshow(rchip, plotnum=(2,3,6), title='inv sqrtm 5') draw_kpts3(kpts1.copy(), 5) df2.update()
def query_last_feature(): viz.show_nearest_descriptors(hs, qcx, last_state.last_fx, df2.next_fnum()) fig3 = df2.gca() df2.connect_callback(fig3, 'button_press_event', _click_chipres_click) df2.update()
def _plotpts(data, px, color=df2.BLUE, label=''): #df2.figure(9003, docla=True, pnum=(1, 1, px)) df2.plot2(data.T[0], data.T[1], '-', '', color=color, label=label) df2.update()