Home > Matching_SYM_LSM > src > 2D_LSM_62 > 2D_LSM_62_sym_Functions > image_pair_approximate_values_weights.m

image_pair_approximate_values_weights

PURPOSE ^

% approximate values for geometric transformation, variance functions

SYNOPSIS ^

function [g,h,x_approx,par] = image_pair_approximate_values_weights(Nig,Nih,Image_l,Image_r,X,par)

DESCRIPTION ^

% approximate values for geometric transformation, variance functions

 wf 7/2020

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [g,h,x_approx,par] = image_pair_approximate_values_weights(Nig,Nih,Image_l,Image_r,X,par)
0002 %% approximate values for geometric transformation, variance functions
0003 %
0004 % wf 7/2020
0005 
0006 %% === estimate noise variances ======================================
0007 if par.readX == 0   % measure image correspondencies
0008     
0009     % --- estimate noise variance g ---------------------------------------
0010     % half size of area for dermining noise variance
0011     DD    = max([100,Nig]);     
0012     [M,N] = size(Image_l);
0013     % determine bounding box within Image_l
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     % estimate noise standard deviations
0019     [s_g,m_g,~] = noise_standard_deviation_estimation(Image_l(x_min:x_max,y_min:y_max,:));
0020     
0021     % take mean of channels
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     % --- estimate noise variance h ---------------------------------------
0030     % half size of area for dermining noise variance
0031     DD    = max([100,Nih]);
0032     [M,N] = size(Image_r);
0033     % determine bounding box within Image_r
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     % estimate noise standard deviations
0039     [s_h,m_h,~] = noise_standard_deviation_estimation(Image_r(x_min:x_max,y_min:y_max,:));
0040     % take mean of channels
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     % show average noise standard deviation over channels
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     % save
0057     save(par.coordinate_name,'X','par');
0058     
0059 else
0060     % load
0061     load(par.coordinate_name,'X','par');
0062     
0063 end
0064 
0065 %% === true affinity referring to centre of window =====================
0066 D = [X(2,3)/X(1,3)*eye(2),[0;0];0 0 1];     % relative scaling
0067 alpha = X(2,4)-X(1,4);                      % rotation
0068 R = [cos(alpha) -sin(alpha) 0;sin(alpha) cos(alpha) 0;0 0 1];
0069 par.A_a   = D*R;                            % similarity
0070 % half transformation A=B^2
0071 par.B_a   = sqrtm(par.A_a);
0072 par.Bi_a  = inv(par.B_a);
0073 
0074 % --- approximate values ----------------------------------------------
0075 par.Ai_a = inv(par.A_a);
0076 % Approximate geometric affinity z = A y
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 %% select windows ======================================================
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

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