Esempio n. 1
0
N1 = sift1.shape[0]
N2 = sift2.shape[0]
dist_thresh = 1.1

matches = -1 * np.ones((sift1.shape[0]), 'int')
dist = np.dot(sift1, sift2.T)
for i in range(0, N1):
    temp = dist[i,:]
    indx = np.argsort(temp)
    indx = indx[::-1]
    if temp[indx[0]] / temp[indx[1]] > dist_thresh:
        matches[i] = indx[0]

# PUT YOUR CODE IN week2.match_sift, SO THAT IT CAN BE CALLED AS
matches = week2.match_sift(sift1, sift2, dist_thresh)

# NOW YOU ARE ABLE TO PLOT THE MATCHES AND GET SOMETHING LIKE IN FIG.1 OF THE HANDOUT
week2.plot_matches(im1, im2, frames1, frames2, matches) # [ALREADY IMPLEMENTED]

# !!! EXPERIMENT FOR DIFFERENT VALUES OF DIST_THRESH AND CONTINUE WITH THAT ONE.
# !!! REPORT THIS VALUE IN YOUR REPORT

##############################################################################
#### PART 3. SIFT FEATURES ARE INVARIANT TO
##############################################################################

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP D: ROTATION (REPEAT FOR 15, 30, 45, 60, 75, 90)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
impath1 = '../../data/oxford_scaled/all_souls_000026.jpg'
Esempio n. 2
0
# NOW YOU ARE ABLE TO PLOT THE MATCHES AND GET SOMETHING LIKE IN FIG.1 OF THE HANDOUT
week2.plot_matches(im1, im2, frames1, frames2, matches) # [ALREADY IMPLEMENTED]

# !!! EXPERIMENT FOR DIFFERENT VALUES OF DIST_THRESH AND CONTINUE WITH THAT ONE.
# !!! REPORT THIS VALUE IN YOUR REPORT
# Rog - Result for assignment in C2
impath1 = '../../data/oxford_scaled/all_souls_000075.jpg'
frames1, sift1 = week2.compute_sift(impath1)
impath2 = '../../data/oxford_scaled/all_souls_000076.jpg'
frames2, sift2 = week2.compute_sift(impath2)

im1 = Image.open(impath2)
im2 = Image.open(impath2)

matches = week2.match_sift(sift1, sift2, 1.15)
week2.plot_matches(im1, im2, frames1, frames2, matches)

##############################################################################
#### PART 3. SIFT FEATURES ARE INVARIANT TO
##############################################################################

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP D: ROTATION (REPEAT FOR 15, 30, 45, 60, 75, 90)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
impath1 = '../../data/oxford_scaled/all_souls_000026.jpg'
frames1, sift1 = week2.compute_sift(impath1)

im1 = Image.open(impath1)

for deg in np.arange(0, 90+15, 15):
Esempio n. 3
0
subplot(1, 2, 1)
im1 = Image.open(impath1)
week2.plot_features(im1, frames1, False, 'r')
subplot(1, 2, 2)
im2 = Image.open(impath2)
week2.plot_features(im2, frames2, False, 'r')

# STEP C.1 NORMALIZE SIFT VECTORS
sift1 = tools.normalizeL2(sift1, 1)
sift2 = tools.normalizeL2(sift2, 1)

# STEP C.2 COMPUTE DISTANCES BETWEEN ALL VECTORS IN SIFT1 AND SIFT2.

# PUT YOUR CODE IN week2.match_sift, SO THAT IT CAN BE CALLED AS
dist_thresh = 1.1
matches, ranked_ratio = week2.match_sift(sift1, sift2, dist_thresh) # [YOU NEED TO IMPLEMENT THIS]
week2.store_cache()

while True:
    rawinput = raw_input('>> ')
    if rawinput == 'q':
        week2.store_cache()
        sys.exit()
    tmp_matches = -1 * np.ones(matches.shape)
    theta = float(rawinput)
    for i in range(len(matches)):
        if ranked_ratio[i] > theta:
            tmp_matches[i] = matches[i]
    print sum(tmp_matches != -1)
    # NOW YOU ARE ABLE TO PLOT THE MATCHES AND GET SOMETHING LIKE IN FIG.1 OF THE HANDOUT
    week2.plot_matches(im1, im2, frames1, frames2, tmp_matches) # [ALREADY IMPLEMENTED]