def plot_kp(img, mode='string'): img = ImageObject(img) img = image_module.convert_to_pgm(img) img = make_keypoints(img) loc, desc = get_descriptors(img) im = get_image_as_array(img) sift.plot_features(im,loc) image_module.remove_temp_files_img(img)
def get_kpm(img1,img2, mode='string' ,less=0, from_index=-1, to_index=-1): # in string mode, img1, img2 parameters are only strings (path to image files) -> testing, presentation, prints out infos # in only_match mode, these are ImageObject objects, no prints. 2 params are 2 [loc,desc] lists if mode=='string': print 'Preparing images...' im1 = None im2 = None loc1, desc1 = None, None loc2, desc2 = None, None # only_match mod eseten a gyorsabb futas miatt csak a match-et nezem, a tobbi erteket elore kiszamolom a kepekre if mode=='string': img1 = image_module.convert_to_pgm(img1) img2 = image_module.convert_to_pgm(img2) img1 = make_keypoints(img1) img2 = make_keypoints(img2) loc1, desc1 = get_descriptors(img1) loc2, desc2 = get_descriptors(img2) im1 = get_image_as_array(img1) im2 = get_image_as_array(img2) elif mode=='only_match': loc1 = img1[0] desc1 = img1[1] loc2 = img2[0] desc2 = img2[1] else: print 'Not supported mode!' exit(-1) if mode=='string': print '\nSearching for matchings...' matchscores = sift.match(desc1, desc2) bool_indexing = False # ezzel a 2 indexxel kivalasztom mettol meddig levo matched keypointokat akarom kirajzolni..atlathatosag if from_index>to_index: from_index = -1 to_index = -1 if from_index!=-1 and to_index!=-1: bool_indexing = True if bool_indexing: if from_index<1: from_index = 1 if to_index>matchscores.size: to_index = matchscores.size # because of the 4x4 storing method in lowe's paper num_keypoints1 = loc1.size/4 num_keypoints2 = loc2.size/4 num_matches = nonzero(matchscores)[0].size if mode=='string': for counter, m in enumerate(matchscores.tolist()): if bool_indexing and (not from_index-1<=counter<=to_index-1): matchscores[counter] = np.float64(0.0) else: # ezzel a parameterrel minden 'less'-edik matchet rajzolja csak ki..atlathatosag miatt ugyancsak if less != 0: if counter % less != 0: matchscores[counter] = np.float64(0.0) print "Number of matching keypoints:", num_matches if mode=='string': print "number of displayed matches:", nonzero(matchscores)[0].size qom, MatchPercent = get_qom(num_keypoints1, num_keypoints2, num_matches) print "Quality of match: ", qom, '\n' return im1, im2, matchscores,qom,MatchPercent