To get started: Fork this repository then issue
git clone --recursive http://github.com/[username]/geometry-processing-smoothing.git
See introduction.
Once built, you can execute the assignment from inside the build/
by running
on a given mesh with given scalar field (in
dmat format).
./smoothing [path to mesh.obj] [path to data.dmat]
or to load a mesh with phony noisy data use:
./smoothing [path to mesh.obj] n
or to load a mesh with smooth z-values as data (for mesh smoothing only):
./smoothing [path to mesh.obj]
In this assignment we will explore how to smooth a data signal defined over a curved surface. The data signal may be a scalar field defined on a static surface: for example, noisy temperatures on the surface of an airplane. Smoothing in this context can be understood as data denoising:
The signal could also be the geometric positions of the surface itself. In this context, smoothing acts also affects the underlying geometry of the domain. We can understand this operation as surface fairing:
In both cases, the underlying mathematics of both operations will be very
similar. If we think of the signal as undergoing a flow toward a smooth
solution over some phony notion of "time", then the governing partial
differential equation we will start with sets the change in signal value
where the scalar parameter
When the signal is the surface geometry, we call this a geometric flow.
There are various ways to motivate this choice of flow for data-/geometry-smoothing. Let us consider one way that will introduce the Laplacian as a form of local averaging.
Given a noisy signal
If the ball
Dividing both sides by
For harmonic functions,
(see, for example, Laplace-Betrami operator case, Laplace operator case.)
Alternatively, we can think of a single smoothing operation as the solution to
an energy minimization problem. If
where again the scalar parameter
In the smooth setting, our energy
We are used to working with minimizing quadratic functions with respect to a discrete set of variables, where the minimum is obtained when the gradient of the energy with respect to the variables is zero.
In our case, the functional
where we observe that
Since
The choice of "test" function
It is difficult to claim much about
where we choose to ignore the boundary terms (for now) or equivalently we
agree to work on closed surfaces
Since this equality must hold of any
The choice of
Because we invoke variations to arrive at this equation, we call the energy-based formulation a variational formulation.
Now we understand that the flow-based formulation and the variational formulation lead to the same system, let us concretely write out the implicit smoothing step.
Letting
where
There are many ways to derive a discrete
approximation of the Laplacian
- finite volume method,
- "The solution of partial differential equations by means of electrical networks" [MacNeal 1949, pp. 68],
- "Discrete differential-geometry operators for triangulated 2-manifolds" [Meyer et al. 2002],
- Polygon mesh processing [Botsch et al. 2010],
- finite element
method,
- "Variational methods for the solution of problems of equilibrium and vibrations" [Courant 1943],
- Algorithms and Interfaces for Real-Time Deformation of 2D and 3D Shapes [Jacobson 2013, pp. 9]
- discrete exterior
calculus
- Discrete Exterior Calculus [Hirani 2003, pp. 69]
- Discrete Differential Geometry: An Applied Introduction [Crane 2013, pp. 71]
- gradient of surface area \Rightarrow mean curvature
flow
- "Computing Discrete Minimal Surfaces and Their Conjugates" [Pinkall & Polthier 1993]
All of these techniques will produce the same sparse Laplacian matrix
We want to approximate the Laplacian of a function
Any piecewise-linear function can be expressed as a sum of values at mesh
vertices times corresponding piecewise-linear basis functions (a.k.a hat
functions,
By plugging this definition into our smoothness energy above, we have discrete energy that is quadratic in the values at each mesh vertex:
By defining
We first notice that
where
Now, consider two neighboring nodes
Now notice that the angle between
So, we can rewrite equation the cosine law equation above into:
Now, apply the definition of sine for right triangles:
where
Combine the cosine and sine terms:
Finally, since
Similarly, inside the other triangle
where
Recall that
Treated as an operator (i.e., when used multiplied against a vector
$$ \int \mathbf{S} (u-f)^{2} \, dA = \int \mathbf{S} {\sum}{i=1}^n {\sum}{j=1}^n {\varphi}_i\cdot {\varphi}_j (u_i-f_i) (u_j-f_j) \, dA = (\mathbf{u}-\mathbf{f})^{\mathsf T} \mathbf{M} (\mathbf{u}-\mathbf{f}), $$
where
This matrix
for a mesh with
If we start directly with the continuous smoothing iteration equation, then we
have a point-wise equality. To fit in our integrated Laplacian
where
Instead, we could take the healthier view of requiring our smoothing iteration equation to hold in a locally integrated sense. In this case, we replace mass matrices on either side:
Now the system matrix
The discrete Laplacian operator and its accompanying mass matrix are
intrinsic operators in the sense that they only depend on lengths. In
practical terms, this means we do not need to know where vertices are
actually positioned in space (i.e.,
This also means that applying a transformation to a shape that does not change any lengths on the surface (e.g., bending a sheet of paper) will have no affect on the Laplacian.
For the data denoising application, our geometry of the domain is not changing
only the scalar function living upon it. We can build our discrete Laplacian
For geometric smoothing, the Laplacian operator (both $\Delta $ in the continuous
setting and
However, if we assume that small changes in
Repeated application of geometric smoothing may cause the mesh to "disappear". Actually the updated vertex values are being set to NaNs due to degenerate numerics. We are rebuilding the discrete Laplacian at every new iteration, regardless of the "quality" of the mesh's triangles. In particular, if a triangle tends to become skinnier and skinnier during smoothing, what will happen to the cotangents of its angles?
In "Can Mean-Curvature Flow Be Made Non-Singular?", Kazhdan et al. derive a new
type of geometric flow that is stable (so long as the mesh at time
The "cotangent Laplacian" by far the most important tool in geometry processing. It comes up everywhere. It is important to understand where it comes from and be able to derive it (in one way or another).
The background section above contains a FEM derivation of the discrete "cotangnet Laplacian". For this (unmarked) task, read and understand one of the other derivations listed above.
Hint: The finite-volume method used in [Botsch et al. 2010] is perhaps the most accessible alternative.
igl::doublearea
igl::edge_lengths
igl::cotmatrix_entries
igl::cotmatrix
igl::massmatrix
- Trig functions
sin
,cos
,tan
etc. (e.g., from#include <cmath>
) See background notes about "intrinisic"-ness
Construct the "cotangent Laplacian" for a mesh with edge lengths l
. Each
entry in the output sparse, symmetric matrix L
is given by:
Hint: Review the law of sines and law of cosines and Heron's ancient formula to derive a formula for the cotangent of each triangle angle that only uses edge lengths.
Construct the diagonal(ized) mass matrix M
for a mesh with given face indices
in F
and edge lengths l
.
Given a mesh (V
,F
) and data specified per-vertex (G
), smooth this data
using a single implicit Laplacian smoothing step.
This data could be a scalar field on the surface and smoothing corresponds to data denoising.
Or the data could be the vector field of the surface's own geometry. This corresponds to geometric smoothing.