1. 程式人生 > >Image Stitching using Python

Image Stitching using Python

Detailed Description

Feature Detection

In this step, we identify points of interest in the image using the Harris corner detection method. For each point in the image, consider a window of pixels around that point. Compute the Harris matrix H for (the window around) that point, defined as

here the Ixp is the is the x derivative of the image at point p, the notation is similar for the y derivative. You should use the Sobel operator to compute the x, y derivatives. The weights should be chosen to be circularly symmetric (for rotation invariance).

H is a 2x2 matrix. To find interest points, first compute the corner strength function as below

Once you’ve computed c for every point in the image, choose points where c is above a threshold.

Use the following command to extract keypoints

dst = cv2.cornerHarris(gray,blockSize,ksize,alpha) 
''' img - Input image, it should be grayscale and float32 type. blockSize - It is the size of neighbourhood considered for corner detection ksize - Aperture parameter of Sobel derivative usedaplha - Harris detector free parameter in the equation. '''
#result is dilated for marking the corners, not important 
dst = cv2.dilate(dst,None) 
# Threshold for an optimal value, it may vary depending on the image. 
img[dst>0.01*dst.max()]=[0,0,255]