def matchPics(I1, I2, opts): #I1, I2 : Images to match #opts: input opts ratio = opts.ratio #'ratio for BRIEF feature descriptor' sigma = opts.sigma #'threshold for corner detection using FAST feature detector' #Convert Images to GrayScale img_1 = rgb2gray(I1) img_2 = rgb2gray(I2) #Detect Features in Both Images locs1 = corner_detection(img_1, sigma) locs2 = corner_detection(img_2, sigma) #Obtain descriptors for the computed feature locations desc1, locs1 = computeBrief(img_1, locs1) desc2, locs2 = computeBrief(img_2, locs2) #print(desc1.shape) #print(locs1.shape) #Match features using the descriptors matches = briefMatch(desc1, desc2, ratio) #print(matches.shape) return matches, locs1, locs2
def matchPics(I1, I2, opts): #I1, I2 : Images to match #opts: input opts ratio = opts.ratio #'ratio for BRIEF feature descriptor' sigma = opts.sigma #'threshold for corner detection using FAST feature detector' #%% #Convert Images to GrayScale # I1 = cv2.imread(I1, 0) I1 = skimage.color.rgb2gray(I1) I2 = skimage.color.rgb2gray(I2) # I2 = cv2.imread(I2, 0) #%% #Detect Features in Both Images # print('Here is good') locs1 = corner_detection(I1, sigma) locs2 = corner_detection(I2, sigma) #%% #Obtain descriptors for the computed feature locations desc1, locs1 = computeBrief(I1, locs1) desc2, locs2 = computeBrief(I2, locs2) #Match features using the descriptors matches = briefMatch(desc1, desc2, ratio) # Change the locs to the corresponding1 # locs1 = locs1[matches[:,0],:] # locs2 = locs2[matches[:,1],:] #%% return matches, locs1, locs2
def matchPics(I1, I2, opts): #I1, I2 : Images to match #opts: input opts ratio = opts.ratio #'ratio for BRIEF feature descriptor' sigma = opts.sigma #'threshold for corner detection using FAST feature detector' locs1 = [] # N x 2 matrix containing x,y coords or matched point pairs locs2 = [] # N x 2 matrix containing x,y coords or matched point pairs matches = [ ] # p x 2 matrix - first col are indices for descriptor of I1 features; 2nd col are indices related to I2 #Convert Images to GrayScale img1_grey = cv2.cvtColor(I1, cv2.COLOR_BGR2GRAY) img2_grey = cv2.cvtColor(I2, cv2.COLOR_BGR2GRAY) #Detect Features in Both Images with corner_detection() fn. locs1 = corner_detection(img1_grey, sigma) locs2 = corner_detection(img2_grey, sigma) #Obtain descriptors for the computed feature locations with computeBrief() fn. img1_descrp, locs1 = computeBrief(img1_grey, locs1) img2_descrp, locs2 = computeBrief(img2_grey, locs2) #Match features using the descriptors matches = briefMatch(img1_descrp, img2_descrp, ratio) return matches, locs1, locs2
def matchPics(I1, I2): # I1, I2 : Images to match # Convert Images to GrayScale I1 = cv2.cvtColor(I1, cv2.COLOR_RGB2GRAY) I2 = cv2.cvtColor(I2, cv2.COLOR_RGB2GRAY) # Detect Features in Both Images locs1 = corner_detection(I1) locs2 = corner_detection(I2) # Obtain descriptors for the computed feature locations desc1, locs1 = computeBrief(I1, locs1) desc2, locs2 = computeBrief(I2, locs2) # Match features using the descriptors locs1 = np.flip(locs1, axis=1) locs2 = np.flip(locs2, axis=1) matches = briefMatch(desc1, desc2, 0.8) print(matches.shape) return matches, locs1, locs2
def matchPics(I1, I2, opts): ratio = opts.ratio #'ratio for BRIEF feature descriptor'] sigma = opts.sigma #'threshold for corner detection using FAST feature detector' #Convert Images to GrayScale I1 = cv2.cvtColor(I1, cv2.COLOR_BGR2GRAY) I2 = cv2.cvtColor(I2, cv2.COLOR_BGR2GRAY) locs1 = corner_detection(I1, sigma) #Detect Features in Both Images locs2 = corner_detection(I2, sigma) #Obtain descriptors for the computed feature locations desc1, locs1 = computeBrief(I1, locs1) #Match features using the descritors desc2, locs2 = computeBrief(I2, locs2) #Match features using the descritors matches = briefMatch(desc1, desc2, ratio) return matches, locs1, locs2
def matchPics(I1, I2): #I1, I2 : Images to match #Convert Images to GrayScale img1 = cv2.cvtColor(I1, cv2.COLOR_BGR2GRAY) img2 = cv2.cvtColor(I2, cv2.COLOR_BGR2GRAY) #Detect Features in Both Images # fast = cv2.FastFeatureDetector_create(threshold = 100, nonmaxSuppression=True) locs1 = corner_detection(img1) locs2 = corner_detection(img2) #Obtain descriptors for the computed feature locations # img1_decs, img1_locs = computeBrief(img1, locs1) img2_decs, img2_locs = computeBrief(img2, locs2) #Match features using the descriptors matches = briefMatch(img1_decs, img2_decs) locs1[:, :] = locs1[:, [1, 0]] locs2[:, :] = locs2[:, [1, 0]] return matches, locs1, locs2