-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update edge indicator function * use k * meshDenoiseViaNormals
- Loading branch information
Showing
2 changed files
with
178 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
#pragma once | ||
|
||
#include "MRMeshFwd.h" | ||
#include "MRProgressCallback.h" | ||
#include "MRExpected.h" | ||
|
||
namespace MR | ||
{ | ||
|
||
/// Smooth face normals, given | ||
/// \param mesh contains topology information and edge lengths for weights | ||
/// \param mesh contains topology information and coordinates for equation weights | ||
/// \param normals input noisy normals and output smooth normals | ||
/// \param v edge indicator: 1 - smooth edge, 0 - crease edge | ||
/// \param gamma the more the value, the larger smoothing is (approximately in the range [1,30]) | ||
/// see the article "Mesh Denoising via a Novel Mumford-Shah Framework" | ||
/// \param v edge indicator function (1 - smooth edge, 0 - crease edge) | ||
/// \param gamma the amount of smoothing: 0 - no smoothing, 1 - average smoothing, ... | ||
/// see the article "Mesh Denoising via a Novel Mumford-Shah Framework", equation (19) | ||
MRMESH_API void denoiseNormals( const Mesh & mesh, FaceNormals & normals, const Vector<float, UndirectedEdgeId> & v, float gamma ); | ||
|
||
/// Update edge indicator function (1 - smooth edge, 0 - crease edge), given | ||
/// \param mesh contains topology information and coordinates for equation weights | ||
/// \param v noisy input and smooth output | ||
/// \param normals per-face normals | ||
/// \param beta 0.001 - sharp edges, 0.01 - moderate edges, 0.1 - smooth edges | ||
/// \param gamma the amount of smoothing: 0 - no smoothing, 1 - average smoothing, ... | ||
/// see the article "Mesh Denoising via a Novel Mumford-Shah Framework", equation (20) | ||
MRMESH_API void updateIndicator( const Mesh & mesh, Vector<float, UndirectedEdgeId> & v, const FaceNormals & normals, float beta, float gamma ); | ||
|
||
struct DenoiseViaNormalsSettings | ||
{ | ||
/// 0.001 - sharp edges, 0.01 - moderate edges, 0.1 - smooth edges | ||
float beta = 0.001f; | ||
/// the amount of smoothing: 0 - no smoothing, 1 - average smoothing, ... | ||
float gamma = 5.f; | ||
/// the number of iterations to smooth normals and find creases; the more the better quality, but longer computation | ||
int normalIters = 10; | ||
/// the number of iterations to update vertex coordinates from found normals; the more the better quality, but longer computation | ||
int pointIters = 20; | ||
/// optionally returns creases found during smoothing | ||
UndirectedEdgeBitSet * outCreases = nullptr; | ||
/// to get the progress and optionally cancel | ||
ProgressCallback cb = {}; | ||
}; | ||
|
||
/// Reduces noise in given mesh, | ||
/// see the article "Mesh Denoising via a Novel Mumford-Shah Framework" | ||
MRMESH_API VoidOrErrStr meshDenoiseViaNormals( Mesh & mesh, const DenoiseViaNormalsSettings & settings = {} ); | ||
|
||
} //namespace MR |