TP-probleme-inverse-3D/TP7/estimation_non_calibree.m
2023-06-25 16:38:01 +02:00

40 lines
889 B
Matlab

function [rho_estime, N_estime] = estimation_non_calibree(I, masque)
masque2 = logical(masque);
[u, s, v] = svds(I(:, masque2(:)));
u_bar = u(:,1:3);
s_bar = s(1:3, 1:3);
v_bar = v(:, 1:3);
S0 = u_bar * s_bar.^(1/2);
M0 = zeros(3, size(I, 2));
M0(:, masque2(:)) = s_bar.^(1/2) * v_bar';
M1 = impose_integrabilite(M0, masque2);
A = M1 / M0;
S1 = S0 / A;
alpha = - mean(M1(1,:)) / mean(M1(3,:));
beta = - mean(M1(2,:)) / mean(M1(3,:));
min_var = +Inf;
for gamma=0.1:0.01:1
Ginv = [ 1 0 -alpha/gamma ; 0 1 -beta/gamma ; 0 0 1/gamma ];
S = S1 * Ginv;
[rho_estime_, N_estime_] = estimation(I, S, masque2);
bidule = std(rho_estime_(:));
if bidule < min_var
min_var = bidule;
rho_estime = rho_estime_;
N_estime = N_estime_;
end
end
end