Home > Matching_SYM_LSM > src > 2D_LSM_62 > 2D_LSM_62_sym > LSM_62_sym_estimate_f.m

LSM_62_sym_estimate_f

PURPOSE ^

estimate function f from g and h using xa and smooth.

SYNOPSIS ^

function [fe,fes,fgi,fhi] = LSM_62_sym_estimate_f(g,h,vg,vh,Nf,xa,sigma,pt)

DESCRIPTION ^

 estimate function f from g and h using xa and smooth.

 g,h       two images
 vg, vh    variance function
 Nf        half size of reference image
 xa        current geometric and radiometic transformation 
 sigma     stdv for smoothing

 fes       estimated and smoothed image

 wf 2018/11

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [fe,fes,fgi,fhi] = LSM_62_sym_estimate_f(g,h,vg,vh,Nf,xa,sigma,pt)
0002 % estimate function f from g and h using xa and smooth.
0003 %
0004 % g,h       two images
0005 % vg, vh    variance function
0006 % Nf        half size of reference image
0007 % xa        current geometric and radiometic transformation
0008 % sigma     stdv for smoothing
0009 %
0010 % fes       estimated and smoothed image
0011 %
0012 % wf 2018/11
0013 
0014 % inverse geoemtric transformation
0015 B  = [xa(1) xa(3) xa(5);xa(2) xa(4) xa(6);0 0 1];
0016 R  = [xa(7);xa(8)];
0017 Bi = inv(B);
0018 
0019 % sizes
0020 Ng = (size(g,1)-1)/2;
0021 
0022 Nh = (size(h,1)-1)/2;
0023 
0024 fe  = zeros(2*Nf+1);
0025 fes = zeros(2*Nf+1);
0026 fgi = zeros(2*Nf+1);
0027 fhi = zeros(2*Nf+1);
0028 
0029 for i=-Nf:Nf
0030     for j=-Nf:Nf
0031         % image g: dermine g-values of grid in f
0032         xgij = Bi * [i;j;1];
0033         xg = xgij(1) + Ng+1;
0034         yg = xgij(2) + Ng+1;
0035         if xg > 2*Ng || yg > 2*Ng || xg < 2  || yg < 2
0036             keyboard
0037         end
0038         %fg = (1+R(1))*LSM_f_spline(xg,yg,g)/255+R(2);
0039         fg =R(1)*LSM_f_cubic_interpolation(xg,yg,g)/255+R(2);
0040         wg = 1/vg(round(fg*255)+1)/R(1)^2;
0041         fgi(i+Nf+1,j+Nf+1) = fg;
0042         
0043         % image h: dermine h-values of grid in f
0044         xhij = B * [i;j;1];
0045         xh = xhij(1) + Nh+1;
0046         yh = xhij(2) + Nh+1;
0047         if xh > 2*Nh || yh > 2*Nh || xh < 2  || yh < 2
0048             keyboard
0049         end
0050         %fh= (LSM_f_spline(xh,yh,h)/255-R(2))/(1+R(1));
0051         fh= (LSM_f_cubic_interpolation(xh,yh,h)/255-R(2))/R(1);
0052         wh = 1/vh(round(fh*255)+1)*R(1)^2;
0053         fhi(i+Nf+1,j+Nf+1) = fh;
0054         
0055         % take weighted average:
0056         fe(i+Nf+1,j+Nf+1) = (wg*fg+wh*fh)/(wg+wh);
0057     end
0058 end
0059 if sigma > 0
0060     % smooth: to be used for derivatives.
0061     fes = gaussFFT(fe,sigma,'G');
0062 else
0063     fes = fe;
0064 end
0065 
0066 if pt > 1
0067     figure('Name','Histogram of residuals of restaured images')
0068     subplot(1,2,1)
0069     hist(fgi(:)-fe(:),2*Nf+1);
0070     title(['mean(g-f) = ',num2str(mean(fgi(:)-fe(:)))])
0071     subplot(1,2,2)
0072     hist(fhi(:)-fe(:),2*Nf+1);
0073     title(['mean(h-f) = ',num2str(mean(fhi(:)-fe(:)))])
0074     Cov_fg=cov(fgi(:),fhi(:));
0075     
0076     %R1_est=sqrt(tan(0.5*atan2(2*Cov_fg(1,2),Cov_fg(2,2)-Cov_fg(1,1))))-1
0077 end
0078 end
0079

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