%matplotlib inline
import math
import numpy as np
import matplotlib.pyplot as plt
from skimage import data
from skimage.color import rgb2gray
from skimage import io
from skimage import transform
from skimage.feature import (match_descriptors, corner_harris,
corner_peaks, ORB, plot_matches)
Here we use the ORB feature detector as an alternative to highlight the principle of matching feature points.
rgb_image = io.imread("../images/mickey-mouse-image.jpg")
image = rgb2gray(rgb_image)
tform = transform.AffineTransform(scale=(1.3, 1.1), rotation=0.5,
translation=(0, -200))
image_t = transform.warp(image, tform)
ffig, ax = plt.subplots(figsize=(12, 12))
ax = plt.subplot(1,2,1)
plt.imshow(image, cmap='gray')
ax.set_title('original image', y=1.05, fontsize=18)
ax = plt.subplot(1,2,2)
plt.imshow(image_t, cmap='gray')
ax.set_title('original image', y=1.05, fontsize=18)
NK = 50
descriptor_extractor = ORB(n_keypoints=NK)
descriptor_extractor.detect_and_extract(image)
keypoints1 = descriptor_extractor.keypoints
descriptors1 = descriptor_extractor.descriptors
descriptor_extractor.detect_and_extract(image_t)
keypoints2 = descriptor_extractor.keypoints
descriptors2 = descriptor_extractor.descriptors
matches = match_descriptors(descriptors1, descriptors2, cross_check=True)
ffig, ax = plt.subplots(figsize=(36, 36))
ax = plt.subplot(1,2,1)
plot_matches(ax, image, image_t, keypoints1, keypoints2, matches)
ax.axis('off')
ax.set_title("Original Image vs. Transformed Image")
plt.show()