if (max(img.size) > 1000 or len(imgList) > 10): img.thumbnail((np.asarray(img.size) * RESIZE).astype('int'), Image.ANTIALIAS) Images.update({idx: img}) print('Images loaded. Beginning feature detection...') #%% Feature detection Descriptor = {} PointInImg = {} for idx, (key, img) in enumerate(sorted(Images.items())): I = np.asarray(img.convert('L')).astype('single') [f, d] = sift(I, compute_descriptor=True, float_descriptors=True) pointsInImage = swapcolumn(f[:, 0:2]) PointInImg.update({idx: pointsInImage}) Descriptor.update({idx: d}) #%% Compute Transformation Transform = {} for idx in range(len(imgList) - 1): print('fitting transformation from ' + str(idx) + ' to ' + str(idx + 1) + '\t') M = SIFTSimpleMatcher(Descriptor[idx], Descriptor[idx + 1], Thre) print('matching points:', len(M, ), '\n') Transform.update({idx: RANSACFit(PointInImg[idx], PointInImg[idx + 1], M)}) #%% Make Panoramic image print('Stitching images...') MultipleStitch(Images, Transform, saveFileName) print('The completed file has been saved as ' + saveFileName) plt.imshow(Image.open(saveFileName))
Descriptor = {} PointInImg = {} for idx, (key, img) in enumerate(sorted(Images.items())): I = np.asarray(img.convert('L')).astype('single') [f,d] = sift(I, compute_descriptor=True, float_descriptors=True) pointsInImage = swapcolumn(f[:,0:2]) PointInImg.update({idx:pointsInImage}) Descriptor.update({idx:d}) # Compute Transformation Transform = {} for idx in range(len(imgList)-1): print('fitting transformation from '+str(idx)+' to '+str(idx+1)+'\t') # M = SIFTSimpleMatcher(Descriptor[idx], Descriptor[idx+1], Thre) M = SIFTKDTreeMatcher(Descriptor[idx], Descriptor[idx+1], Thre) print('matching points:',len(M,),'\n') Transform.update({idx:RANSACFit(PointInImg[idx], PointInImg[idx+1], M)}) # Make Panoramic image print('Stitching images...') Pano = MultipleStitch(Images, Transform) # Savefig result = Image.fromarray(Pano) result = result.convert("RGB") result.save(saveFileName) print('The completed file has been saved as '+saveFileName) # plt.imshow(Image.open(saveFileName))