From 7c01bca811467679f535ef292f6393e256e1acec Mon Sep 17 00:00:00 2001 From: Nils Moehrle Date: Wed, 18 Jan 2017 21:06:09 +0100 Subject: [PATCH] Introduce regularization for global seam leveling #63 --- libs/tex/global_seam_leveling.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/tex/global_seam_leveling.cpp b/libs/tex/global_seam_leveling.cpp index 7a05cb81..7ad56858 100644 --- a/libs/tex/global_seam_leveling.cpp +++ b/libs/tex/global_seam_leveling.cpp @@ -240,8 +240,13 @@ global_seam_leveling(UniGraph const & graph, mve::TriangleMesh::ConstPtr mesh, SpMat A(A_rows, x_rows); A.setFromTriplets(coefficients_A.begin(), coefficients_A.end()); - SpMat Lhs = A.transpose() * A + Gamma.transpose() * Gamma; - /* Only keep lower triangle (CG only uses the lower), prune the rest and compress matrix. */ + SpMat I(x_rows, x_rows); + I.setIdentity(); + + SpMat Lhs = A.transpose() * A + Gamma.transpose() * Gamma + I * 0.0001f; + + /* Only keep lower triangle (CG only uses the lower), + * prune the rest and compress matrix. */ Lhs.prune([](const int& row, const int& col, const float& value) -> bool { return col <= row && value != 0.0f; }); // value != 0.0f is only to suppress a compiler warning