Skip to content

Commit

Permalink
added option to stay close to a depth map for Christoph
Browse files Browse the repository at this point in the history
  • Loading branch information
yvain queau committed Jul 31, 2018
1 parent 4995997 commit 8577a3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Toolbox/near_ps.m
Expand Up @@ -63,6 +63,8 @@
% - PARAMS.lambda: parameter of the robust estimator
% (default: 0, since LS estimator requires no estimator)
% (we recommend e.g. 0.1 for Cauchy)
% - PARAMS.zeta: hyper-parameter controlling how close we stay from z0
% (default: 0)
% - PARAMS.self_shadows: binary variable indicating if
% self-shadows are included in the model or not
% (default: 1)
Expand Down Expand Up @@ -239,6 +241,14 @@
if(~strcmp(estimator,'LS') & lambda == 0)
disp('ERROR: a strictly positive estimator parameter must be set in PARAMS.lambda for robust M-estimation');
end
% Check fidelity's parameter
if(~isfield(params,'zeta'))
params.zeta = 0;
end
zeta = params.zeta; clear params.zeta;
if(zeta < 0)
disp('ERROR: a positive fidelity must be set in PARAMS.zeta');
end
% Check self shadows
if(~isfield(params,'self_shadows'))
disp('WARNING: self_shadows parameter not provided in PARAMS.self_shadows, using default values')
Expand Down Expand Up @@ -572,6 +582,7 @@
energy = energy+J_fcn(rho_tilde(:,ch),psi(:),Ich(:),phich,Wch(:));
end
energy = energy./(npix*nimgs*nchannels);
energy = energy + zeta*sum((z_tilde(:)-z0(:)).^2)/npix;
clear Ich psich
disp(sprintf('== it. 0 - energy : %.20f',energy));
disp(' ');
Expand Down Expand Up @@ -650,9 +661,11 @@
At = transpose(A);
M = At*spdiags(D(:),0,nimgs*npix*nchannels,nimgs*npix*nchannels)*A;
M = M/(nimgs*npix*nchannels);
M = M+zeta*speye(npix)/npix;

rhs = repmat(chi,[1 nchannels]).*(rho_rep).*(rho_rep.*(-repmat(psi,[1 nchannels]))+reshape(I,npix,nimgs*nchannels)).*reshape(w,npix,nimgs*nchannels);
rhs = At*rhs(:)/(nimgs*npix*nchannels);
rhs = rhs+zeta*(z0(:)-z_tilde(:))/npix;
clear rho_rep

% Recompute the preconditioner every 5 iterations
Expand Down
3 changes: 2 additions & 1 deletion demo_1_calibrated_gray_LS_ps.m
Expand Up @@ -80,8 +80,9 @@
params.estimator = 'LS'; % Least-squares estimation
params.scales = 8; % Number of pyramid levels
params.ratio = 1; % Downsample by ratio>1 for faster results
params.self_shadows = 0; % Do not explicitly take into account self-shadows
params.self_shadows = 1; % Do or do not explicitly take into account self-shadows
params.display = 1; % Do not display result at each iteration
params.zeta = 0.0; % Fidelity to z0 ==> CHRISTOPH: THIS PARAMETER CONTROLS WHAT YOU WANT

%%% Solve photometric stereo
disp('Solving photometric stereo');
Expand Down

0 comments on commit 8577a3e

Please sign in to comment.