0001 function [g,h,x_approx,par] = image_pair_approximate_values_weights(Nig,Nih,Image_l,Image_r,X,par)
0002
0003
0004
0005
0006
0007 if par.readX == 0
0008
0009
0010
0011 DD = max([100,Nig]);
0012 [M,N] = size(Image_l);
0013
0014 x_min = max([1,X(1,1)-DD]);
0015 y_min = max([1,X(1,2)-DD]);
0016 x_max = min([M,X(1,1)+DD]);
0017 y_max = min([N,X(1,2)+DD]);
0018
0019 [s_g,m_g,~] = noise_standard_deviation_estimation(Image_l(x_min:x_max,y_min:y_max,:));
0020
0021
0022 stg = mean(s_g,1)'*256;
0023
0024 display(['avg. noise std [gr] left : ', ...
0025 num2str(mean(stg))])
0026
0027 par.vg = stg.^2;
0028
0029
0030
0031 DD = max([100,Nih]);
0032 [M,N] = size(Image_r);
0033
0034 x_min = max([1,X(2,1)-DD]);
0035 y_min = max([1,X(2,2)-DD]);
0036 x_max = min([M,X(2,1)+DD]);
0037 y_max = min([N,X(2,2)+DD]);
0038
0039 [s_h,m_h,~] = noise_standard_deviation_estimation(Image_r(x_min:x_max,y_min:y_max,:));
0040
0041 sth = mean(s_h,1)'*255;
0042 display(['avg. noise std [gr] right : ', ...
0043 num2str(mean(sth))])
0044
0045 par.vh = sth.^2;
0046
0047
0048 figure('name','noise standard deviations');
0049 hold on
0050 plot(mean(s_g,1)*255,'-b','LineWidth',2);
0051 plot(mean(s_h,1)*255,'-r','LineWidth',2);
0052 title('Noise standard deviations: left (blue), right(red)')
0053 xlim([min([m_g(:);m_h(:)]),max([m_g(:);m_h(:)])]*255)
0054 ylim([0,1.1*max([mean(s_g,1)'*255;mean(s_h,1)'*255])])
0055
0056
0057 save(par.coordinate_name,'X','par');
0058
0059 else
0060
0061 load(par.coordinate_name,'X','par');
0062
0063 end
0064
0065
0066 D = [X(2,3)/X(1,3)*eye(2),[0;0];0 0 1];
0067 alpha = X(2,4)-X(1,4);
0068 R = [cos(alpha) -sin(alpha) 0;sin(alpha) cos(alpha) 0;0 0 1];
0069 par.A_a = D*R;
0070
0071 par.B_a = sqrtm(par.A_a);
0072 par.Bi_a = inv(par.B_a);
0073
0074
0075 par.Ai_a = inv(par.A_a);
0076
0077 disp([ 'Scale difference : ',num2str(X(2,3)/X(1,3))])
0078 disp([ 'Rotation difference : ',num2str(alpha*180/pi), '°'])
0079 disp( 'Geometric affinity z = A y : ')
0080 disp(par.A_a);
0081
0082 x_approx = [reshape(par.A_a(1:2,:),6,1);par.R_a'];
0083
0084
0085
0086 g = round(mean(Image_l(X(1,1)-Nig:X(1,1)+Nig,X(1,2)-Nig:X(1,2)+Nig,:),3));
0087 h = round(mean(Image_r(X(2,1)-Nih:X(2,1)+Nih,X(2,2)-Nih:X(2,2)+Nih,:),3));
0088
0089 if par.plot_type > 0
0090 figure('name','left and right image window')
0091 subplot(1,2,1)
0092 imshow(g/255)
0093 title('left')
0094 subplot(1,2,2)
0095 imshow(h/255)
0096 title('right')
0097 end
0098
0099
0100 end
0101