def cof(): im1 = np.array(Image.open(inpfilename).convert('L')) im2 = np.array(Image.open(inpfilename).convert('L')) wid = 5 harrisim = harris.compute_harris_response(im1,5) filtered_coords1 = harris.get_harris_points(harrisim, wid+1) d1 = harris.get_descriptors(im1, filtered_coords1,wid) harrisim = harris.compute_harris_response(im2,5) filtered_coords2 = harris.get_harris_points(harrisim, wid+1) d2 = harris.get_descriptors(im2, filtered_coords2,wid) print 'starting matching' matches = harris.match_twosided(d1,d2) print "matches", matches figure() gray() harris.plot_matches(im1, im2, filtered_coords1, filtered_coords2, matches) print "show the image" show()
# -*- coding: utf-8 -*- """ Created on Mon Aug 15 11:19:46 2016 @author: user """ from PIL import Image from pylab import * import harris im = array(Image.open('../ch1/baby_16.jpg').convert('L')) harrisim = harris.compute_harris_response(im) filtered_coords = harris.get_harris_points(harrisim, 6) harris.plot_harris_points(im, filtered_coords) imshow(im) wid = 5 im1 = array(Image.open('../ch1/baby_1.jpg').convert('L')) harrisim = harris.compute_harris_response(im1, 5) filtered_coords1 = harris.get_harris_points(harrisim, wid + 1) d1 = harris.get_descriptors(im1, filtered_coords1, wid) im2 = array(Image.open('../ch1/baby_16.jpg').convert('L')) harrisim = harris.compute_harris_response(im2, 5) filtered_coords2 = harris.get_harris_points(harrisim, wid + 1) d2 = harris.get_descriptors(im2, filtered_coords2, wid) print 'starting matching' matches = harris.match_twosided(d1, d2) figure() gray() harris.plot_matches(im1, im2, filtered_coords1, filtered_coords2, matches) show()
print 'matching one way' matches_12 = match_features(desc1, desc2) print 'matching other way' matches_21 = match_features(desc2, desc1) print 'culling matches' idx_12 = matches_12.nonzero()[0] for i in idx_12: if matches_21[int(matches_12[i])] != i: matches_12[i] = 0 return matches_12 if __name__ == '__main__': im1, im2 = [ process_image('data/crans_%d_small.jpg' % i, 'output/im%d.sift' % i) for i in (1, 2) ] l1, d1 = read_features_from_file('output/im1.sift') l2, d2 = read_features_from_file('output/im2.sift') matches = match_features(d1, d2) print matches[:50] pylab.figure() pylab.gray() harris.plot_matches(im1, im2, l1[:, :2], l2[:, :2], matches) pylab.show()
t = time.time() filtered_coords1 = harris.get_harris_points(harrisim, wid + 1) print "t for get_harris_points=", time.time() - t t = time.time() d1 = harris.get_descriptors(im1, filtered_coords1, wid) print "t for get_descriptors=", time.time() - t t = time.time() harrisim = harris.compute_harris_response(im2, 5) filtered_coords2 = harris.get_harris_points(harrisim, wid + 1) d2 = harris.get_descriptors(im2, filtered_coords2, wid) print "starting matching" matches = harris.match_twosided(d1, d2) figure() gray() harris.plot_matches(im1, im2, filtered_coords1, filtered_coords2, matches) show() """ im = array(Image.open('empire.jpg').convert('L')) harrisim = harris.compute_harris_response(im) filtered_coords = harris.get_harris_points(harrisim,6) harris.plot_harris_points(im, filtered_coords) """
im1 = array(Image.open(imname1).convert('L')) sift.process_image(imname1,'ti1.sift') l1,d1 = sift.read_features_file('./ti1.sift') im2 = array(Image.open(imname2).convert('L')) sift.process_image(imname2,'ti2.sift') l2,d2 = sift.read_features_file('./ti2.sift') locs1 = l1[:,:2] locs2 = l2[:,:2] matchscore = sift.match_twoside(d1,d2) print(locs1.shape) print(locs2.shape) print(matchscore.shape) print(matchscore.max()) print(locs1[24,1]) #figure() #sift.plot_feature(im1,l1,circle = True) #show() figure() harris.plot_matches(im1,im2,locs1,locs2,matchscore) show()
print "Running Harris Corner detection for", image1, "and", image2 print "For the following number of iterations:", num_runs else: print 'No image specified' print 'Run as follows: serial_mapping.py <image1.png> <image2.jpg>\n' # Run Harris Get Corners for Image 1 Harris_Matrix_1, serial_points_1, parallel_points_1, output_times_openCL_1, \ output_times_serial_1 = harris_get_corners(num_runs, image1) # Run Harris Get Corners for Image 1 Harris_Matrix_2, serial_points_2, parallel_points_2, output_times_openCL_2, \ output_times_serial_2 = harris_get_corners(num_runs, image2) # Run Parallel Matching and Sort with Parallel Harris corners match_parallel = parallel_match_sort(Harris_Matrix_1, Harris_Matrix_2, \ parallel_points_1, parallel_points_2) # Run Parallel Matching and Sort with Parallel Harris corners match_serial = serial_matching(Harris_Matrix_1, Harris_Matrix_2, \ serial_points_1, serial_points_2) # Plot Parallel Matches plot_matches(image1, image2, parallel_points_1, parallel_points_2, \ match_parallel, 'parallel_match.jpg') # Plot Serial Matches plot_matches(image1, image2, serial_points_1, serial_points_2, \ match_serial, 'serial_match.jpg')
from pylab import * import harris #import imtools im1 = array(Image.open('/Users/taronegeorage/Desktop/111.jpg').convert('L')) im2 = array(Image.open('/Users/taronegeorage/Desktop/111.jpg').convert('L')) harrisim1 = harris.compute_harris_response(im1) filtered_coords1 = harris.get_harris_points(harrisim1) patches1 = harris.get_descriptors(im1, filtered_coords1) harris.plot_harris_points(im1, filtered_coords1) harrisim2 = harris.compute_harris_response(im2) filtered_coords2 = harris.get_harris_points(harrisim2) patches2 = harris.get_descriptors(im2, filtered_coords2) harris.plot_harris_points(im2, filtered_coords2) matches = harris.match_twosided(patches1, patches2) figure() gray() harris.plot_matches(im1, im2, filtered_coords1, filtered_coords2, matches, show_below=False) show()
from PIL import Image from pylab import * import harris import imtools im1 = array(Image.open('/Users/thakis/src/PCV/data/sf_view1.jpg').convert('L')) im2 = array(Image.open('/Users/thakis/src/PCV/data/sf_view2.jpg').convert('L')) harrisim1 = harris.compute_harris_response(im1) filtered_coords1 = harris.get_harris_points(harrisim1) patches1 = harris.get_descriptors(im1, filtered_coords1) harris.plot_harris_points(im1, filtered_coords1) harrisim2 = harris.compute_harris_response(im2) filtered_coords2 = harris.get_harris_points(harrisim2) patches2 = harris.get_descriptors(im2, filtered_coords2) harris.plot_harris_points(im2, filtered_coords2) matches = harris.match_twosided(patches1, patches2) figure() gray() harris.plot_matches(im1, im2, filtered_coords1, filtered_coords2, matches, show_below=False) show()
def match_twosided(desc1, desc2): print 'matching one way' matches_12 = match_features(desc1, desc2) print 'matching other way' matches_21 = match_features(desc2, desc1) print 'culling matches' idx_12 = matches_12.nonzero()[0] for i in idx_12: if matches_21[int(matches_12[i])] != i: matches_12[i] = 0 return matches_12 if __name__ == '__main__': im1, im2 = [ process_image('data/crans_%d_small.jpg' % i, 'output/im%d.sift' % i) for i in (1, 2) ] l1, d1 = read_features_from_file('output/im1.sift') l2, d2 = read_features_from_file('output/im2.sift') matches = match_features(d1, d2) print matches[:50] pylab.figure() pylab.gray() harris.plot_matches(im1, im2, l1[:,:2], l2[:,:2], matches) pylab.show()
import numpy as np import matplotlib.pyplot as plt from PIL import Image from harris import compute_harris_response, get_harris_points, \ get_descriptors, match_two_sided, plot_matches, match img1 = np.array(Image.open('images/house.jpg').convert('L')) img2 = np.array(Image.open('images/house2.jpg').convert('L')) wid = 100 harris_img = compute_harris_response(img1, 5) filtered_coords1 = get_harris_points(harris_img, wid + 1) d1 = get_descriptors(img1, filtered_coords1, wid) harris_img = compute_harris_response(img2, 5) filtered_coords2 = get_harris_points(harris_img, wid + 1) d2 = get_descriptors(img2, filtered_coords2, wid) print('[INFO] Starting Matching ') matches = match(d1, d2) print('[INFO] match complete') plt.figure() plt.gray() plot_matches(img1, img2, filtered_coords1, filtered_coords2, matches) plt.show()