0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 close all
0018 clearvars
0019
0020
0021 addpath(genpath('src/'))
0022
0023 disp(' --------------------------------------------------------------------- ')
0024 disp(' ---- Symmetric LSM with 6 geometric and 2 radiometric parameters ---- ')
0025 disp(' -------------- two images with corresponding keypoints -------------- ')
0026 disp(' --------------------------------------------------------------------- ')
0027
0028
0029
0030
0031 plot_type = 1;
0032 max_iter = 9;
0033 sigma_smooth = 0;
0034
0035
0036
0037 load('example_data/Sym_LSM_medium_demo');
0038
0039
0040
0041
0042 figure('name','left and right images')
0043 subplot(1,2,1)
0044 imshow(Image_l)
0045 hold on
0046 plot_circle_direction_with_background(X(1,2),X(1,1),3*X(1,3),X(1,4),8,4)
0047 title('left')
0048 subplot(1,2,2)
0049 imshow(Image_r)
0050 hold on
0051 plot_circle_direction_with_background(X(2,2),X(2,1),3*X(2,3),X(2,4),8,4)
0052 title('right')
0053
0054
0055
0056
0057 Nig = round(4*X(1,3));
0058 Nih = round(4*X(2,3));
0059
0060
0061 g = round(mean(Image_l(X(1,1)-Nig:X(1,1)+Nig,X(1,2)-Nig:X(1,2)+Nig,:),3));
0062 h = round(mean(Image_r(X(2,1)-Nih:X(2,1)+Nih,X(2,2)-Nih:X(2,2)+Nih,:),3));
0063
0064 figure('name','left and right image window')
0065 subplot(1,2,1)
0066 imshow(g/255)
0067 title('left')
0068 subplot(1,2,2)
0069 imshow(h/255)
0070 title('right')
0071
0072
0073
0074 DD = 100;
0075
0076
0077
0078 [M,N] = size(Image_l);
0079 x_min = max([1,X(1,1)-DD]); y_min = max([1,X(1,2)-DD]);
0080 x_max = min([M,X(1,1)+DD]); y_max = min([N,X(1,2)+DD]);
0081
0082 [s_g,m_g,~] = noise_standard_deviation_estimation(Image_l(x_min:x_max,y_min:y_max,:));
0083
0084
0085
0086 [M,N] = size(Image_r);
0087 x_min = max([1,X(2,1)-DD]); y_min = max([1,X(2,2)-DD]);
0088 x_max = min([M,X(2,1)+DD]); y_max = min([N,X(2,2)+DD]);
0089
0090 [s_h,m_h,~] = noise_standard_deviation_estimation(Image_r(x_min:x_max,y_min:y_max,:));
0091
0092
0093 vg = (mean(s_g,1)'*256).^2;
0094 vh = (mean(s_h,1)'*256).^2;
0095
0096 figure('name','noise standard deviations');
0097 hold on
0098 plot(mean(s_g,1)*255,'-b','LineWidth',2);
0099 plot(mean(s_h,1)*255,'-r','LineWidth',2);
0100 title('Noise standard deviations: left (blue), right(red)')
0101 xlim([min([m_g(:);m_h(:)]),max([m_g(:);m_h(:)])]*255)
0102 ylim([0,1.1*max([mean(s_g,1)'*255;mean(s_h,1)'*255])])
0103
0104
0105
0106 D = [X(2,3)/X(1,3)*eye(2),[0;0];0 0 1];
0107 alpha = X(2,4)-X(1,4);
0108 R = [cos(alpha) -sin(alpha) 0;sin(alpha) cos(alpha) 0;0 0 1];
0109 A_a = D*R;
0110
0111 R_a = [1,0];
0112
0113 Nf_MIN = 4;
0114
0115
0116 disp([ 'approximate scale difference : ',num2str(X(2,3)/X(1,3))])
0117 disp([ 'approximate rotation difference : ',num2str(alpha*180/pi), '°'])
0118 disp( 'approximate geometric affinity z = A y : ')
0119 disp(A_a);
0120
0121 disp(['approximate intensity transformation h = b7*y + b8 [gr] : [',...
0122 num2str(R_a(1)),',',num2str(R_a(2)*255),']'])
0123 x_approx = [reshape(A_a(1:2,:),6,1);R_a'];
0124
0125
0126 disp(['Maximum number of iterations : ', num2str(max_iter)])
0127
0128
0129 disp(['Minimum size of overlap : ', num2str(Nf_MIN),'x', num2str(Nf_MIN)])
0130
0131
0132 disp(['Smoothing kernel [pixels] : 0'])
0133
0134
0135
0136
0137 disp('=== Iteration sequence =======================================')
0138
0139 [est_x,est_sigma_0,NN,Nf,Red,N_iter] = LSM_62_sym_warp_main...
0140 (g,h,vg,vh,A_a,R_a,sigma_smooth,max_iter,Nf_MIN,1);
0141
0142
0143 A_est = [reshape(est_x.x(1:6),2,3);0 0 1];
0144 Rm_est = [ est_x.x(7:8)';0 1];
0145 Ai_est = A_est;
0146
0147 image_pair_analyse(...
0148 A_a, ...
0149 R_a, ...
0150 Ai_est, ...
0151 Red, ...
0152 est_sigma_0, ...
0153 est_x, ...
0154 1,0);
0155
0156 disp(' --------------------------------- ')
0157 disp(' ---- end demo symmetric LSM ---- ')
0158 disp(' --------------------------------- ')
0159
0160