def get_gaussian_weight_patch(gauss_shape=(19, 19), gauss_sigma_frac=.3, gauss_norm_01=True): r""" 2d gaussian image useful for plotting Returns: ndarray: patch CommandLine: python -m vtool.coverage_kpts --test-get_gaussian_weight_patch Example: >>> # ENABLE_DOCTEST >>> from vtool.coverage_kpts import * # NOQA >>> # build test data >>> # execute function >>> patch = get_gaussian_weight_patch() >>> # verify results >>> result = str(patch) >>> print(result) """ # Perdoch uses roughly .95 of the radius radius = gauss_shape[0] / 2.0 sigma = gauss_sigma_frac * radius # Similar to SIFT's computeCircularGaussMask in helpers.cpp # uses smmWindowSize=19 in hesaff for patch size. and 1.6 for sigma # Create gaussian image to warp patch = ptool.gaussian_patch(shape=gauss_shape, sigma=sigma) if gauss_norm_01: np.divide(patch, patch.max(), out=patch) return patch
def get_gaussian_weight_patch( gauss_shape=(19, 19), gauss_sigma_frac=.3, gauss_norm_01=True): r""" 2d gaussian image useful for plotting Returns: ndarray: patch CommandLine: python -m vtool.coverage_kpts --test-get_gaussian_weight_patch Example: >>> # ENABLE_DOCTEST >>> from vtool.coverage_kpts import * # NOQA >>> # build test data >>> # execute function >>> patch = get_gaussian_weight_patch() >>> # verify results >>> result = str(patch) >>> print(result) """ # Perdoch uses roughly .95 of the radius radius = gauss_shape[0] / 2.0 sigma = gauss_sigma_frac * radius # Similar to SIFT's computeCircularGaussMask in helpers.cpp # uses smmWindowSize=19 in hesaff for patch size. and 1.6 for sigma # Create gaussian image to warp patch = ptool.gaussian_patch(shape=gauss_shape, sigma=sigma) if gauss_norm_01: np.divide(patch, patch.max(), out=patch) return patch
def TEST_figure1(wpatch, gradx, grady, gmag, gori, hist, centers): print('[rotinvar] 4) Draw histogram with interpolation annotations') fnum = 1 gorimag = plottool.color_orimag(gori, gmag, True) nRow, nCol = (2, 7) df2.figure(fnum=1, pnum=(nRow, 1, nRow), doclf=True, docla=True) plottool.draw_hist_subbin_maxima(hist, centers) df2.set_xlabel('grad orientation (radians)') df2.set_ylabel('grad magnitude') df2.set_title('dominant orientations') print('[rotinvar] 5) Show patch, gradients, magintude, and orientation') df2.imshow(wpatch, pnum=(nRow, nCol, 1), fnum=fnum, title='patch') df2.draw_vector_field(gradx, grady, pnum=(nRow, nCol, 2), fnum=fnum, title='gori (vec)') df2.imshow(gorimag, pnum=(nRow, nCol, 3), fnum=fnum, title='gori (col)') df2.imshow(np.abs(gradx), pnum=(nRow, nCol, 4), fnum=fnum, title='gradx') df2.imshow(np.abs(grady), pnum=(nRow, nCol, 5), fnum=fnum, title='grady') df2.imshow(gmag, pnum=(nRow, nCol, 6), fnum=fnum, title='gmag') gpatch = ptool.gaussian_patch(shape=gori.shape) df2.imshow(gpatch * 255, pnum=(nRow, nCol, 7), fnum=fnum, title='gauss weights', cmap_='hot') #gpatch3 = np.dstack((gpatch, gpatch, gpatch)) #df2.draw_vector_field(gradx * gpatch, grady * gpatch, pnum=(nRow, nCol, 8), fnum=fnum, title='gori (vec)') #df2.imshow(gorimag * gpatch3, pnum=(nRow, nCol, 9), fnum=fnum, title='gori (col)') #df2.imshow(gradx * gpatch, pnum=(nRow, nCol, 10), fnum=fnum, title='gradx') #df2.imshow(grady * gpatch, pnum=(nRow, nCol, 11), fnum=fnum, title='grady') #df2.imshow(gmag * gpatch, pnum=(nRow, nCol, 12), fnum=fnum, title='gmag') return locals()
def get_annot_match_covimg(ibs, aid, sel_fx, mx2_score, **kwargs): chip = ibs.get_annot_chips(aid) kpts = ibs.get_annot_kpts(aid) mx2_kp = kpts[sel_fx] srcimg = ptool.gaussian_patch() # 2 and 3 are scale modes if kwargs.get('method', 0) in [2, 3]: # Bigger keypoints should get smaller weights mx2_scale = np.sqrt([a * d for (x, y, a, c, d) in mx2_kp]) mx2_score = mx2_score / mx2_scale dstimg = warp_srcimg_to_kpts(mx2_kp, srcimg, chip.shape[0:2], fx2_score=mx2_score, **kwargs) return dstimg
def get_coverage_map(kpts, chip_shape, **kwargs): # Create gaussian image to warp np.tau = 2 * np.pi srcimg = ptool.gaussian_patch() dstimg = warp_srcimg_to_kpts(kpts, srcimg, chip_shape, **kwargs) return dstimg