Commit 70c63026 authored by Laurent Belcour's avatar Laurent Belcour

Updating the paper for small changes.

Adding an option to fit using the log transformation in the CERES fitter.
Updating the export scripts for the retro data.
parent 2446b882
......@@ -20,10 +20,12 @@ ALTA_DLL_EXPORT fitter* provide_fitter()
class CeresFunctor : public ceres::CostFunction
{
public:
CeresFunctor(nonlinear_function* f, const vec& xi, bool cos_fit = false) : _f(f), _xi(xi), _cos_fit(cos_fit)
CeresFunctor(nonlinear_function* f, const vec& xi, const arguments& args) : _f(f), _xi(xi)
{
set_num_residuals(f->dimY());
mutable_parameter_block_sizes()->push_back(f->nbParameters());
_log_fit = args.is_defined("log-fit");
}
virtual bool Evaluate(double const* const* x, double* y, double** dy) const
......@@ -51,23 +53,16 @@ class CeresFunctor : public ceres::CostFunction
_di[i] = _xi[_f->dimX() + i];
}
// Should add the resulting vector completely
double costerm = 1.0;
if(_cos_fit)
{
double _x[6];
params::convert(&_xi[0], _f->input_parametrization(), params::CARTESIAN, _x);
costerm = _x[5]*_x[2];
}
vec _y = _di - _f->value(_xi);
const vec _yi = _f->value(_xi);
const vec _y = _di - _yi;
for(int i=0; i<_f->dimY(); ++i)
{
y[i] = _y[i];
y[i] = (_log_fit) ? log(1.0 + _di[i]) - log(1.0 + _yi[i]) : _y[i] ;
}
if(dy != NULL)
{
df(dy);
df(_di, dy);
}
return true;
......@@ -75,7 +70,7 @@ class CeresFunctor : public ceres::CostFunction
// The parameter of the function _f should be set prior to this function
// call. If not it will produce undesirable results.
virtual void df(double ** fjac) const
virtual void df(const vec& di, double ** fjac) const
{
// Get the jacobian of the function at position x_i for the current
// set of parameters (set prior to function call)
......@@ -88,16 +83,19 @@ class CeresFunctor : public ceres::CostFunction
// Fill the columns of the matrix
for(int j=0; j<_f->nbParameters(); ++j)
{
fjac[0][i*_f->nbParameters() + j] = -_jac[i*_f->nbParameters() + j];
fjac[0][i*_f->nbParameters() + j] = - ((_log_fit) ? _jac[i*_f->nbParameters() + j]/(1.0 + di[i]) : _jac[i*_f->nbParameters() + j]);
}
}
}
protected:
bool _cos_fit;
const vec _xi;
// Data point and function to optimize
nonlinear_function* _f;
const vec _xi;
// Arguments of the fitting procedure
bool _log_fit;
};
nonlinear_fitter_ceres::nonlinear_fitter_ceres()
......@@ -124,9 +122,6 @@ bool nonlinear_fitter_ceres::fit_data(const data* d, function* fit, const argume
}
nonlinear_function* nf = dynamic_cast<nonlinear_function*>(fit);
// Should I include the cosine term during the fit ?
const bool cos_fit = args.is_defined("cos-fit");
#ifndef DEBUG
std::cout << "<<DEBUG>> number of parameters: " << nf->nbParameters() << std::endl;
#endif
......@@ -158,7 +153,7 @@ bool nonlinear_fitter_ceres::fit_data(const data* d, function* fit, const argume
xf[nf->dimX() + k] = xi[d->dimX() + k];
}
problem.AddResidualBlock(new CeresFunctor(nf, xf, cos_fit), NULL, &p[0]);
problem.AddResidualBlock(new CeresFunctor(nf, xf, args), NULL, &p[0]);
}
// Solves the NL problem
......
......@@ -6,24 +6,25 @@ set key on inside left
# output ABC fits
set output "yellow_retro_abc.tex"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_abc_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro ABC fit", "./results/3d/retro/half/3M_jaune_abc_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back ABC fit"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_abc_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro ABC fit" w points pointtype 12, "./results/3d/retro/half/3M_jaune_abc_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back ABC fit"
# output Beckmann fits
set output "yellow_retro_beck.tex"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_beck_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro Beckmann fit", "./results/3d/retro/half/3M_jaune_beck_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back Beckmann fit"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_beck_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro Beckmann fit" w points pointtype 12, "./results/3d/retro/half/3M_jaune_beck_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back Beckmann fit"
# output Blinn fits
set output "yellow_retro_blinn.tex"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_blinn_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro Blinn fit", "./results/3d/retro/half/3M_jaune_blinn_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back Blinn fit"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_blinn_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro Blinn fit" w points pointtype 12, "./results/3d/retro/half/3M_jaune_blinn_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back Blinn fit"
# output Lafotune fit
set output "yellow_retro_laf.tex"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_laf.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Lafortune fit"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_laf.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Lafortune fit"
set ylabel "BRDF x cosine"
# output rational fits
set term unknown
set term wxt
set ylabel "BRDF x cosine"
plot "../papers/retro/mesures/original/3M_jaune/3d/633nm/Fichiers definitifs/densify_helmholtz/3M_jaune_3D+3DS+3DR_dense__nbsgrid_162.alta" using (180/pi*$2):($2 > 0.0 && $3 > -0.01 && $3 < 0.01 ? $4 : 1/0) title "Yellow cloth data", "./results/3d/retro/half/3M_jaune_rat_TK2TL.dat" using (180/pi*$2):($2 > 0.0 && $3 > -0.01 && $3 < 0.01) ? $4 : 1/0 title "rational interpolation"
set term epslatex standalone color font 8
......
......@@ -5,24 +5,24 @@ set ylabel "BRDF"
# output ABC fits
set output "gray_retro_abc.tex"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_abc_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro ABC fit", "./results/3d/retro/half/Bande_fluo_abc_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back ABC fit"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_abc_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro ABC fit" w points pointtype 12, "./results/3d/retro/half/Bande_fluo_abc_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back ABC fit"
# output Beckmann fits
set output "gray_retro_beck.tex"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_beck_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro Beckmann fit", "./results/3d/retro/half/Bande_fluo_beck_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back Beckmann fit"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_beck_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro Beckmann fit" w points pointtype 12, "./results/3d/retro/half/Bande_fluo_beck_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back Beckmann fit"
# output Blinn fits
set output "gray_retro_blinn.tex"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_blinn_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro Blinn fit", "./results/3d/retro/half/Bande_fluo_blinn_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back Blinn fit"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_blinn_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro Blinn fit" w points pointtype 12, "./results/3d/retro/half/Bande_fluo_blinn_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back Blinn fit"
# output Lafotune fit
set output "gray_retro_laf.tex"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_laf.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Lafortune fit"
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_laf.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Lafortune fit"
set ylabel "BRDF x cosine"
# output Lafotune fit
set terminal unknown
set terminal wxt
plot "../papers/retro/mesures/original/Bande_fluo_grise/3d/633nm/Fichiers\ definitifs/densityHelmholtz/Bande_grise_3D+3DS+3DR_dense__nbsgrid_162.alta" using (180/pi*$2):($2 > 0.0 && $3 > -0.01 && $3 < 0.01 ? $4 : 1/0) title "Gray cloth data", "./results/3d/retro/half/Bande_fluo_rat_TK2TL.dat" using (180/pi*$2):($2 > 0.0 && $3 > -0.01 && $3 < 0.01 ? $4 : 1/0) title "Rational interpolation"
set term epslatex standalone color font 8
......
......@@ -5,24 +5,24 @@ set ylabel "BRDF"
# output ABC fits
set output "orange_retro_abc.tex"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_abc_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro ABC fit", "./results/3d/retro/half/Bande_orange_abc_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back ABC fit"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_abc_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro ABC fit" w points pointtype 12, "./results/3d/retro/half/Bande_orange_abc_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back ABC fit"
# output Beckmann fits
set output "orange_retro_beck.tex"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_beck_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro Beckmann fit", "./results/3d/retro/half/Bande_orange_beck_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back Beckmann fit"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_beck_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro Beckmann fit" w points pointtype 12, "./results/3d/retro/half/Bande_orange_beck_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back Beckmann fit"
# output Blinn fits
set output "orange_retro_blinn.tex"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_blinn_retro.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "retro Blinn fit", "./results/3d/retro/half/Bande_orange_blinn_back.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "back Blinn fit"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_blinn_retro.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "retro Blinn fit" w points pointtype 12, "./results/3d/retro/half/Bande_orange_blinn_back.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "back Blinn fit"
# output Lafotune fit
set output "orange_retro_laf.tex"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_laf.dat" using (180/pi*$2):($3 > 0.0 && $3 < 0.005 ? $4 : 1/0) title "Lafortune fit"
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_laf.dat" using (180/pi*$2):($3 > -0.001 && $3 < 0.001 ? $4 : 1/0) title "Lafortune fit"
set ylabel "BRDF x cosine"
# output Rational fit
set term unknown
set term wxt
plot "../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D_dense__nbsgrid_162.alta" using (180/pi*$2):($2 > 0.0 && $3 > -0.01 && $3 < 0.05 ? $4 : 1/0) title "Orange cloth data", "./results/3d/retro/half/Bande_orange_rat_TK2TL.dat" using (180/pi*$2):($2 > 0.0 && $3 > -0.01 && $3 < 0.05 ? $4 : 1/0) title "Rational interpolation"
set term epslatex standalone color font 8
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment