Skip to content

Instantly share code, notes, and snippets.

@ankit-maverick
Created September 19, 2013 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankit-maverick/6625616 to your computer and use it in GitHub Desktop.
Save ankit-maverick/6625616 to your computer and use it in GitHub Desktop.
import numpy as np
from skimage import data
from skimage import transform as tf
from skimage.feature import pairwise_hamming_distance, brief, match_keypoints_brief, corner_harris, corner_peaks, keypoints_orb, descriptor_orb
from skimage.color import rgb2gray
from skimage import img_as_float
import matplotlib.pyplot as plt
rotate = np.pi/2
translate = (512, 0)
scaling = (1, 1)
img_color = data.lena()
tform = tf.AffineTransform(scale = scaling, rotation=rotate, translation=translate)
transformed_img_color = tf.warp(img_color, tform)
img = rgb2gray(img_color)
transformed_img = rgb2gray(transformed_img_color)
#plt.gray()
#plt.imshow(transformed_img)
#plt.show()
keypoints1, orientations1, scales1 = keypoints_orb(img, n_keypoints=250)
keypoints1.shape
descriptors1, keypoints1 = descriptor_orb(img, keypoints1, orientations1, scales1)
keypoints1.shape
descriptors1.shape
keypoints2, orientations2, scales2 = keypoints_orb(transformed_img, n_keypoints=250)
keypoints2.shape
descriptors2, keypoints2 = descriptor_orb(transformed_img, keypoints2, orientations2, scales2)
keypoints2.shape
descriptors2.shape
pairwise_hamming_distance(descriptors1, descriptors2)
matched_keypoints = match_keypoints_brief(keypoints1, descriptors1, keypoints2, descriptors2, threshold=0.3)
print "Pairs of matched keypoints :\n"
print matched_keypoints
matched_keypoints.shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment