def wrapper(): #SET 1 im1 = np.array(Image.open('SET1_L.jpg').convert('RGB')) im2 = np.array(Image.open('SET1_M.jpg').convert('RGB')) im3 = np.array(Image.open('SET1_R.jpg').convert('RGB')) #DEFINING THE INPUT IMAGE MATRIX img_input = np.zeros((3, ), dtype='object') img_input[0] = im1 img_input[1] = im2 img_input[2] = im3 #GETTING THE FINAL MOSAIC final_mosaic = mymosaic(img_input) #PLOTTING THE FINAL MOSAIC plt.imshow(final_mosaic) plt.show() ''' ############################################################################## #SET 2 im1 = np.array(Image.open('SET2_L.jpg').convert('RGB')) im2 = np.array(Image.open('SET2_M.jpg').convert('RGB')) im3 = np.array(Image.open('SET2_R.jpg').convert('RGB')) #DEFINING THE INPUT IMAGE MATRIX img_input = np.zeros((3,),dtype='object') img_input[0] = im1 img_input[1]= im2 img_input[2]= im3 #GETTING THE FINAL MOSAIC final_mosaic = mymosaic(img_input) #PLOTTING THE FINAL MOSAIC plt.imshow(final_mosaic) plt.show() ############################################################################## ''' '''
# plt.scatter(x=xR+width, y=yR, c='r', s=5) # plt.plot([x2R[i]+width,x1MR[i]],[y2R[i],y1MR[i]],'y-',linewidth=2) # plt.show() # count += 1 # print() print("HL:") print(HL) print("HR:") print(HR) print("ransac complete") #%% Frame Mosaicing # Call function img_mosaic = mymosaic(imgL, imgM, imgR, HL, HR) # Show Mosaic cv2.namedWindow('Mosaic', cv2.WINDOW_NORMAL) cv2.resizeWindow('Mosaic', 1200, 400) cv2.imshow('Mosaic', img_mosaic.astype(np.uint8)) cv2.waitKey(0) cv2.destroyAllWindows() #%% OpenCV Sanity Check ## Compute homographies #src_pts = np.float32([(x,y) for x,y in zip(x2L,y2L)]).reshape(-1, 1, 2) #dst_pts = np.float32([(x,y) for x,y in zip(x1ML,y1ML)]).reshape(-1, 1, 2) #hlCV,mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0) #src_pts = np.float32([(x,y) for x,y in zip(x2R,y2R)]).reshape(-1, 1, 2)
from matplotlib import pyplot as plt import cv2 import numpy as np import utilities from mymosaic import * import sys # more sets of images available in the images/ folder! imgL = cv2.imread('images/shoemaker-left.jpg') imgM = cv2.imread('images/shoemaker-middle.jpg') imgR = cv2.imread('images/shoemaker-right.jpg') # find left -> middle homography and right->middle homography HLM = utilities.get_homography(imgL,imgM,False,"L") HRM = utilities.get_homography(imgR,imgM,False,"R") canvas = mymosaic(imgL,imgM,imgR,HLM,HRM) if cv2.imwrite("output.png",canvas): print("Output saved to output.png")
from PIL import Image from helper import * import sys from mymosaic import * iarray = [ Image.open("test_img/S1.jpg"), Image.open("test_img/S2.jpg"), Image.open("test_img/S3.jpg"), Image.open("test_img/S5.jpg"), Image.open("test_img/S6.jpg") ] mymosaic(iarray)
# Feature Detection cimg = corner_detector(grayL) # Adaptive Non-Maximal Suppression max_pts = x,y,rmax = anms(cimg, max_pts) # Feature Descriptors descsL = feat_desc(grayL, xL, yL) descsM = feat_desc(grayM, xM, yM) descsR = feat_desc(grayR, xR, yR) # Feature Matching match = feat_match(descs1, descs2) # RAndom Sampling Consensus (RANSAC) H, inlier_ind = ransac_est_homography(x1, y1, x2, y2, thresh) # Frame Mosaicing img_mosaic = mymosaic(img_input) # Show Image Code #cv2.namedWindow('Left Image', cv2.WINDOW_NORMAL) #cv2.resizeWindow('Left Image', 600, 600) #cv2.imshow('Left Image',imgL) #cv2.waitKey(0) #cv2.destroyAllWindows()