def sift_matrix(): featurelist = sift_feature_listnames_generator() imlist = getFiles( '/home/aurora/hdd/workspace/PycharmProjects/data/N20040103G/') nbr_images = len(imlist) matchscores = np.zeros((nbr_images, nbr_images)) for i in range(nbr_images): for j in range(i, nbr_images): # print 'comparing ', imlist[i], imlist[j] l1, d1 = sift.read_feature_from_file(featurelist[i]) l2, d2 = sift.read_feature_from_file(featurelist[j]) if d1.shape[0] == 0 or d2.shape[0] == 0: matchscores[i, j] = 0 else: matches = sift.match_twosided(d1, d2) nbr_matches = sum(matches > 0) print 'number of matches = ', nbr_matches matchscores[i, j] = nbr_matches for i in range(nbr_images): for j in range(i + 1, nbr_images): matchscores[j, i] = matchscores[i, j] np.save( '/home/aurora/hdd/workspace/PycharmProjects/data/aurora_img_matches_matrix_20151212', matchscores) print matchscores
def sift_distance(desc1, desc2): matchs = sift.match_twosided(desc1, desc2) desc1 = np.array([d/np.linalg.norm(d) for d in desc1]) desc2 = np.array([d/np.linalg.norm(d) for d in desc2]) values = 0.0 counts = 0 for i, m in enumerate(matchs): # print 'the value of i '+str(i)+' the value of m is '+str(m) if m > 0: scores = np.dot(desc1[i, :], desc2[m, :].T) values += scores counts += 1 if counts==0: return 0 else: return values/counts
def sift_distance(desc1, desc2): matchs = sift.match_twosided(desc1, desc2) desc1 = np.array([d / np.linalg.norm(d) for d in desc1]) desc2 = np.array([d / np.linalg.norm(d) for d in desc2]) values = 0.0 counts = 0 for i, m in enumerate(matchs): # print 'the value of i '+str(i)+' the value of m is '+str(m) if m > 0: scores = np.dot(desc1[i, :], desc2[m, :].T) values += scores counts += 1 if counts == 0: return 0 else: return values / counts
def sift_matrix(): featurelist = sift_feature_listnames_generator() imlist = getFiles('/home/aurora/hdd/workspace/PycharmProjects/data/N20040103G/') nbr_images = len(imlist) matchscores = np.zeros((nbr_images, nbr_images)) for i in range(nbr_images): for j in range(i, nbr_images): # print 'comparing ', imlist[i], imlist[j] l1, d1 = sift.read_feature_from_file(featurelist[i]) l2, d2 = sift.read_feature_from_file(featurelist[j]) if d1.shape[0] == 0 or d2.shape[0] == 0: matchscores[i, j] = 0 else: matches = sift.match_twosided(d1, d2) nbr_matches = sum(matches > 0) print 'number of matches = ', nbr_matches matchscores[i, j] = nbr_matches for i in range(nbr_images): for j in range(i + 1, nbr_images): matchscores[j, i] = matchscores[i, j] np.save('/home/aurora/hdd/workspace/PycharmProjects/data/aurora_img_matches_matrix_20151212', matchscores) print matchscores