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

image_pair_noise_variances

PURPOSE ^

% estimate noise varainces of images

SYNOPSIS ^

function par = image_pair_noise_variances(Nig,Nih,Image_l,Image_r,X,par)

DESCRIPTION ^

% estimate noise varainces of images

 Nig, Nih          radius of windows
 Image_l,Image_r   left and right image
 X                 2x4 matrix of correspoinindg points (x,y,s,d)
 par               parameter-struct

 par.vg, par.vh    256x1 vectors (LUT) for noise variance 
                   Var(g) = LUT(g+1)
 par.A_true        true geometric affinity
 par.B_true        true half geometric affinity
 par.Bi_true       true half inverse geometric affinity
 par.A_a           approximate geometric affinity
 par.B_a           approximate half geometric affinity

 wf 7/2020

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function par = image_pair_noise_variances(Nig,Nih,Image_l,Image_r,X,par)
0002 %% estimate noise varainces of images
0003 %
0004 % Nig, Nih          radius of windows
0005 % Image_l,Image_r   left and right image
0006 % X                 2x4 matrix of correspoinindg points (x,y,s,d)
0007 % par               parameter-struct
0008 %
0009 % par.vg, par.vh    256x1 vectors (LUT) for noise variance
0010 %                   Var(g) = LUT(g+1)
0011 % par.A_true        true geometric affinity
0012 % par.B_true        true half geometric affinity
0013 % par.Bi_true       true half inverse geometric affinity
0014 % par.A_a           approximate geometric affinity
0015 % par.B_a           approximate half geometric affinity
0016 %
0017 % wf 7/2020
0018 
0019 
0020 %% === estimate noise variances g ======================================
0021 % --- half size of area for dermining noise variance -------------------
0022 DD    = max([100,Nig]);
0023 [M,N] = size(Image_l);
0024 x_min = max([1,X(1,1)-DD]);
0025 y_min = max([1,X(1,2)-DD]);
0026 x_max = min([M,X(1,1)+DD]);
0027 y_max = min([N,X(1,2)+DD]);
0028 [s_g,m_g,~] = noise_standard_deviation_estimation(Image_l(x_min:x_max,y_min:y_max,:));
0029 
0030 stg          = mean(s_g)'*256;
0031 
0032 display(['avg. noise std [gr] left                         : ', ...
0033     num2str(mean(stg))])
0034 par.vg        = stg.^2;
0035 
0036 
0037 %% === estimate noise variances h =======================================
0038 
0039 % half size of area for dermining noise variance
0040 DD    = max([100,Nih]);
0041 [M,N] = size(Image_r);
0042 x_min = max([1,X(2,1)-DD]);
0043 y_min = max([1,X(2,2)-DD]);
0044 x_max = min([M,X(2,1)+DD]);
0045 y_max = min([N,X(2,2)+DD]);
0046 
0047 [s_h,m_h,~] = noise_standard_deviation_estimation(Image_r(x_min:x_max,y_min:y_max,:));
0048 
0049 sth          = mean(s_h)'*255;
0050 display(['avg. noise std [gr] right                        : ', ...
0051     num2str(mean(sth))])
0052 
0053 par.vh        = sth.^2;
0054 
0055 %% === true affinity referring to centre of window =====================
0056 D = [X(2,3)/X(1,3)*eye(2),[0;0];0 0 1];
0057 alpha = X(2,4)-X(1,4);
0058 R = [cos(alpha) -sin(alpha) 0;sin(alpha) cos(alpha) 0;0 0 1];
0059 par.A_true   = D*R;
0060 % half transformation A=B^2
0061 par.B_true   = sqrtm(par.A_true);
0062 par.Bi_true  = inv(par.B_true);
0063 
0064 % --- approximate values ----------------------------------------------
0065 par.A_a  = par.A_true;
0066 par.Ai_a = inv(par.A_a);
0067 % Approximate geometric affinity z = B y
0068     display([ 'Scale difference                                 : ',num2str(X(2,3)/X(1,3))])
0069     display([ 'Rotation difference                              : ',num2str(alpha*180/pi), '°'])
0070     display( 'Geometric affinity       z = B y                 : ')
0071     display(A_a);
0072 
0073 
0074 %% select windows ======================================================
0075 
0076 Nih = round(factor_s*X(2,3));
0077 
0078         
0079 g = round(mean(Image_l(X(1,1)-Nig:X(1,1)+Nig,X(1,2)-Nig:X(1,2)+Nig,:),3));
0080 h = round(mean(Image_r(X(2,1)-Nih:X(2,1)+Nih,X(2,2)-Nih:X(2,2)+Nih,:),3));
0081 
0082 if plot_type > 1
0083     figure(9)
0084     subplot(max_iter+1,4,1)
0085     imshow(g/255)
0086     title('left')
0087     subplot(max_iter+1,4,2)
0088     imshow(h/255)
0089     title('right')
0090 end
0091 
0092 %%
0093 
0094 figure('name','noise standard deviations');
0095 hold on
0096 plot(mean(s_g)*255,'-b','LineWidth',2);
0097 plot(mean(s_h)*255,'-r','LineWidth',2);
0098 title('Noise standard deviations: left (blue), right(red)')
0099 xlim([min([m_g(:);m_h(:)]),max([m_g(:);m_h(:)])]*255)
0100 ylim([0,1.1*max([mean(s_g)'*255;mean(s_h)'*255])])
0101 
0102 end
0103

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