Home > Matching_SYM_LSM > demo_LSM_image_pairs.m

demo_LSM_image_pairs

PURPOSE ^

% demo Sym-LSM from real images

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% demo Sym-LSM from real images

 The demo routine demo_LSM_image_pairs.m allows to apply Sym-LSM 
 to real data. Approximate values can be provided interactively, 
 or - later - read from file. This refers to the centre of the 
 two windows, their individual scale  and their individual main 
 direction, following the notion of scale and direction of 
 Lowe's keypoints.  

 main control parameters
 =======================
 img_name_1    = name of first image
 img_name_2    = name of first image
 read_X        = 0/1 interactively define points,/ read points
 s,t           = parameters for noise sigma_n^2=s+t*f
 sigma         = smoothing kernel size, if = 0: no smoothing
 N_iter        = maximum number of iterations
 
 
 wf 11/2018

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% demo Sym-LSM from real images
0002 %
0003 % The demo routine demo_LSM_image_pairs.m allows to apply Sym-LSM
0004 % to real data. Approximate values can be provided interactively,
0005 % or - later - read from file. This refers to the centre of the
0006 % two windows, their individual scale  and their individual main
0007 % direction, following the notion of scale and direction of
0008 % Lowe's keypoints.
0009 %
0010 % main control parameters
0011 % =======================
0012 % img_name_1    = name of first image
0013 % img_name_2    = name of first image
0014 % read_X        = 0/1 interactively define points,/ read points
0015 % s,t           = parameters for noise sigma_n^2=s+t*f
0016 % sigma         = smoothing kernel size, if = 0: no smoothing
0017 % N_iter        = maximum number of iterations
0018 %
0019 %
0020 % wf 11/2018
0021 
0022 
0023 
0024 clearvars
0025 close all
0026 
0027 addpath(genpath('src/')) 
0028 
0029 par.ss = plot_init();
0030 
0031 disp(' --------------------------------------------------------------------- ')
0032 disp(' ---- symmetric LSM with 6 geometric and 2 radiometric parameters ---- ')
0033 disp(' ----              interactive correspondences                    ---- ')
0034 disp(' --------------------------------------------------------------------- ')
0035 
0036 % suppress warning, that image is too large for display
0037 warning('off','images:initSize:adjustingMag')
0038 
0039 %% Choose your own parameters (default = 2)
0040 % --- type data --------------------------------------------------------
0041     % par.type_data = 1;  % Desert
0042      par.type_data = 2;  % Stockholm
0043     % par.type_data = 3;  % % Peking
0044     % par.type_data = 4;   % % Prag
0045 
0046 %% Parameters ==========================================================
0047 par = image_pair_set_parameters(par);
0048 
0049 %% Images and coordinates
0050 [Nig,Nih,Image_l,Image_r,X,par] = image_pair_provide_images_and_coordinates(par);
0051 
0052 %% approximate values and weights
0053 [g,h,x_approx,par] = image_pair_approximate_values_weights(Nig,Nih,Image_l,Image_r,X,par);
0054  
0055 
0056 % ---  minimum size of overlap  ------------------------------
0057 Nf_MIN = par.Nf_MIN;
0058 disp(['Minimum size of overlap                                  : ', num2str(Nf_MIN),'x', num2str(Nf_MIN)])
0059 
0060 %% start  ===========================================================
0061 
0062 % set parameters
0063 vg              = par.vg;           % 256x1 noise variance function g
0064 vh              = par.vh;           % 256x1 noise variance function h
0065 A_a             = par.A_a;          % 3x3 approx. geometric transformation
0066 R_a             = par.R_a;          %1x2  approx. geometric transformation
0067 sigma_smooth    = par.sigma_smooth; % smoothing parameter for f
0068 max_iter        = par.max_iter;      % maximal number of iterations
0069 plot_type       = par.plot_type     % in [0,1,2] level of output
0070 
0071 % activate for more details
0072 % plot_type = 2;
0073 
0074 % for generating input data for demo_LSM_small.m
0075 % save('example_data/Sym_LSM_small_demo','g','h','vg','vh','A_a','R_a')
0076 
0077 
0078 % for generating input data for demo_LSM_medium.m
0079 % save('example_data/Sym_LSM_medium_demo','Image_l','Image_r','X')
0080 
0081 tic;
0082 % --- estimate transformation (LSM_62_sym_main) ----------------- ---
0083 
0084 [est_x,est_sigma_0,NN,Nf,Red,N_iter] = LSM_62_sym_warp_main...
0085     (g,h,vg,vh,A_a,R_a,sigma_smooth,max_iter,Nf_MIN,plot_type);
0086 
0087 % --- estimate transformation (LSM_62_sym_main) --------------------
0088 LSM_time=toc
0089 
0090 
0091 
0092 if Red > 0 
0093     
0094     A_est   = [reshape(est_x.x(1:6),2,3);0 0 1];
0095     Rm_est  = [ est_x.x(7:8)';0 1];
0096     Ai_est  = A_est;
0097     if par.test_symmetry
0098         disp('--- start symmetric estimation h->g ---')
0099         Ai_a = inv(A_a);
0100         Ri_a = [1/R_a(1),-R_a(2)/R_a(1)]
0101        
0102         % --- estimate transformation (LSM_62_sym_main) --------------------
0103 
0104         [est_xi,est_sigma_0i,NN,Nf,Redi,N_iter] = LSM_62_sym_warp_main...
0105             (h,g,vh,vg,Ai_a,Ri_a,sigma_smooth,max_iter,Nf_MIN,plot_type);
0106 
0107         % --- estimate transformation (LSM_62_sym_main) --------------------
0108         
0109         Ai_est  = [reshape(est_xi.x(1:6),2,3);0 0 1]
0110         Ami_est = [est_xi.x(7:8)';0 1]
0111     end
0112    
0113 
0114 
0115 %% === analyse result ===================================================
0116 
0117 image_pair_analyse(...
0118     A_a,  ...
0119     R_a, ...
0120     Ai_est, ...
0121     Red, ...
0122     est_sigma_0, ...
0123     est_x, ...
0124     par.plot_type,par.test_symmetry)
0125 end
0126 disp(' --------------------------------------------------------------------- ')
0127 disp(' ---- symmetric LSM with 6 geometric and 2 radiometric parameters ---- ')
0128 disp(' ----                            end                              ---- ')
0129 disp(' --------------------------------------------------------------------- ')
0130 
0131 return

Generated on Sun 19-Jul-2020 23:00:25 by m2html © 2005