% demo_function_homography_from_two_images: determination of homography between two image pairs see PCV Sect. 10.3, Fig. 10.18 demo_homography(Image_name_l,Image_name_r,magnification, readX, grid_out, point_transfer) Image_name_l,Image_name_r = input images (left_image.ext,right_imga.ext) imgages may be the same magnification = magnification factor for standard ellipses readX = 0 Control points are determined, interactively, Points need to be given in the following sequence: for each point: left image (figure1), right image (figure 2) sequence = around a quadrangle (not following a diagonal), e.g. 1 ---- 2 | | 4------3 ~= 0 read in of control points, read from file left_imag.mat grid out = [Nx,xa,xe,Ny,ya,y] w.r.t. unit square 00 01 11 10 e.g. [3,0,1,3,0,1] -> 3x3 grid covering unit square [0,1]^2 e.g. [4,-1,2,5,-1,2] -> 4x4 grid covering square [-1,2]^2 point_transfer = 0 not demo of point transfer ~=0 demo of point transfer: provide point in left image transferred point shown in right image with confidence ellipse stop interaction with pressing key, or Control C on console Samples with prepared homographies; examples = 1,2 Wolfgang Förstner 3/2011 wfoerstn@uni-bonn.de last changes: Susanne Wenzel 06/18 wenzel@igg.uni-bonn.de ........................................................................
0001 %% demo_function_homography_from_two_images: 0002 % determination of homography between two image pairs 0003 % 0004 % see PCV Sect. 10.3, Fig. 10.18 0005 % 0006 % demo_homography(Image_name_l,Image_name_r,magnification, 0007 % readX, 0008 % grid_out, 0009 % point_transfer) 0010 % 0011 % Image_name_l,Image_name_r = input images (left_image.ext,right_imga.ext) 0012 % imgages may be the same 0013 % magnification = magnification factor for standard ellipses 0014 % readX = 0 Control points are determined, interactively, 0015 % Points need to be given in the following sequence: 0016 % for each point: left image (figure1), right image (figure 2) 0017 % sequence = around a quadrangle (not following a diagonal), e.g. 0018 % 1 ---- 2 0019 % | | 0020 % 4------3 0021 % ~= 0 read in of control points, read from file left_imag.mat 0022 % grid out = [Nx,xa,xe,Ny,ya,y] w.r.t. unit square 00 01 11 10 0023 % e.g. [3,0,1,3,0,1] -> 3x3 grid covering unit square [0,1]^2 0024 % e.g. [4,-1,2,5,-1,2] -> 4x4 grid covering square [-1,2]^2 0025 % point_transfer = 0 not demo of point transfer 0026 % ~=0 demo of point transfer: 0027 % provide point in left image 0028 % transferred point shown in right image with confidence 0029 % ellipse 0030 % 0031 % stop interaction with pressing key, or Control C on console 0032 % 0033 % Samples with prepared homographies; examples = 1,2 0034 % 0035 % Wolfgang Förstner 3/2011 0036 % wfoerstn@uni-bonn.de 0037 % 0038 % last changes: Susanne Wenzel 06/18 0039 % wenzel@igg.uni-bonn.de 0040 % 0041 % ........................................................................ 0042 0043 clearvars 0044 close all 0045 0046 % choose example 0047 % example = 1; % Busstation 0048 example = 2; % Facade 0049 0050 addpath(genpath('../../General-Functions')) 0051 addpath(genpath('../Functions')) 0052 0053 global print_option_estimation 0054 0055 %% Initialize 0056 sugr_INIT; 0057 print_option_estimation = 0; 0058 0059 switch example 0060 case 1 0061 Image_name_l = 'Images/IMG_1067-Hamburg-04.JPG'; 0062 Image_name_r = 'Images/IMG_1065-Hamburg-04.JPG'; 0063 magnification = 3; 0064 readX = 1; 0065 grid_out = [3,0,1,3,0,1]; 0066 point_transfer = 1; 0067 case 2 0068 Image_name_l = 'Images/IMG_1209-sect-1.JPG'; 0069 Image_name_r = 'Images/IMG_1209-sect-1.JPG'; 0070 magnification = 3; 0071 readX = 1; 0072 grid_out = [4,-1,2,4,-1,2]; 0073 point_transfer = 1; 0074 end 0075 0076 [Image_l,Image_r] = h_init(Image_name_l,Image_name_r); 0077 0078 %% determine H 0079 [H,X] = determine_Homography_2D_from_two_images(Image_l,Image_r,readX); 0080 close all 0081 0082 %% Transfer grid 0083 h_transfer_grid(H,X,Image_l,Image_r,magnification,grid_out); 0084 0085 %% Transfer single points 0086 if point_transfer ~= 0 0087 h_transfer_points(H,X,Image_l,Image_r,magnification); 0088 end 0089 0090 0091 0092