def find_features(pyr): ############################################################# # finds features in an image given by its pyramid pyr ############################################################# pos = sad.spread_out_corners(pyr[0], 7, 7, 12) desc = sample_descriptor(pyr[2], pos, 3) return pos, desc
def find_features(pyr: list) -> tuple: """ get simplified version of the MOPS descriptors from the given pyramid and the positions of them :param pyr: Gaussian pyramid of a grayscale image having 3 levels :return: the positions of the descriptors and array of them [with shape (1+2*desc_rad,1+2*desc_rad,N)] """ pos = sol4_add.spread_out_corners(pyr[0], N, M, RADIUS) desc = sample_descriptor(pyr[2], pos / 4, DEFAULT_DESC_RAD) return pos, desc
def find_features(pyr): """ pyr − Gaussian pyramid of a grayscale image having 3 levels. pos − An array with shape (N,2) of [x,y] feature location per row found in the (third pyramid level of the) image. These coordinates are provided at the pyramid level pyr[0]. desc − A feature descriptor array with shape (K,K,N). """ pos = sol4_add.spread_out_corners(pyr[0], 7, 7, 3) pos_3 = pos[:] / 4 desc = sample_descriptor(pyr[2], pos_3) return pos, desc
def find_features(pyr): """ Takes in a gaussian pyramid of an image with 3 levels, find intersting features and return their location, as well as their corresponding descriptors :param pyr: Gaussian pyramid of a grayscale image having 3 levels. :return: pos − An array with shape (N,2) of [x,y] feature location per row found in the (third pyramid level of the) image. These coordinates are provided at the pyramid level pyr[0]. desc − A feature descriptor array with shape (K,K,N). """ pos = sol4_add.spread_out_corners(pyr[0], M, N, SPOC_RADIUS) pos_flipped = np.fliplr(pos) pos_in_l3 = map_coord_2_level(pos_flipped) desc = sample_descriptor(pyr[2], pos_in_l3, DESC_RADIUS) # remove false descriptors (constant) k = desc.shape[0] mask = np.where( np.sum(np.sum(( 0 == desc).astype(np.uint8), axis=0), axis=0) == k**2)[0] desc = np.delete(desc, mask, axis=2) pos = np.delete(pos, mask, axis=0) return pos, desc
def test_harris_detector(): im = read_image('external/oxford2.jpg', 1) plt.figure() res = spread_out_corners(im, 7, 7, 15) plt.imshow(im, cmap=plt.cm.gray) plt.scatter(res[:, 0], res[:, 1]) # plt.show(block=True) for pth in [ 'external/oxford2.jpg', 'external/office1.jpg', 'external/office2.jpg' ]: plt.figure() im = read_image(pth, 1) res = sol4.harris_corner_detector(im) plt.imshow(im, cmap=plt.cm.gray) plt.scatter(res[:, 0], res[:, 1]) pyr, f = build_gaussian_pyramid(im, 3, 3) plt.figure() im = pyr[2] res = sol4.harris_corner_detector(im) plt.imshow(im, cmap=plt.cm.gray) plt.scatter(res[:, 0], res[:, 1]) plt.show(block=True)
def find_features(pyr): desc_rad = 3 pos = sol4_add.spread_out_corners(pyr[0], 7, 7, desc_rad * 4) desc = sample_descriptor(pyr[2], pos, desc_rad) return pos, desc
def find_features(pyr, radius=3, m=5, n=5): points = spread_out_corners(pyr[0], m, n, radius * 4) # im using radius times 4 because in the next function im using orig radius return points, sample_descriptor(pyr[2], points / 4, radius) # how cool is it to write 2 lines function :)
def find_features(pyr): pos = add.spread_out_corners(pyr[0],7,7,12) #TODO should we use 3? return pos,sample_descriptor(pyr[2],pos,3)