Surface Smoothing
Motivation
Given a scanned of a ball, due to the noise in scanning, the formed mesh may not be smooth, i.e. the transition in normal/tangent is not continuous. Therefore, we want to smooth it out.
Mathematically, we have a data signal over a curved surface, the data signal may be - Data denoising a scalar field defined on a static surface, we want the function of the data signal on the surface to be smooth - Surface fairing the geometric position of the surface itself, we want the underlying geometry of the domain to be smoothed.
Formation of the System
Flow-based Formation
We can think of the signal as undergoing a flow toward a smooth solution over some phony notion of "time", then we should have the PDE being set as the change in signal value \(u\) over time proportional to the Laplacian of the signal
where \(u\) is the function of the signal, \(\Delta\) is the Laplacian operator and \(\lambda\) is the rate of smoothing.
Given a noisy signal \(f\), intuitively we can smooth by average values with its neighborings. If we average of the small ball of nearby points, then we can have smoothing function
If \(\delta\) is small, then we will have to repeat the smoothing multiple times to see a global smoothing. Hence, we can write the current value \(u^t\) flows toward smooth solution by small step \(\Delta t\) in time
Subtracting current \(u^t(x)\) from both sides and introducing a flow-speed parameter \(\lambda\), we will have the flow equation describing the change in values as an integral of relative values
For harmonic functions, \(\Delta u =0\), this integral becomes zero in the limit as the \(\delta\rightarrow 0\) via satisfaction of MVT. If follows for a non-harmonic \(\Delta u\neq 0\), this integral is equal to the Laplacian of \(u\), i.e.
Energy-based Formation
Alternatively, think of a single smoothing operation as the solution to an minimization problem. If \(f\) is the noisy signal, then we want to find a signal \(u\) that it simultaneously minimizes its difference with \(f\) and minimizes its variation over the surface
where \(\lambda\) is the rate of smoothing.
Note that \(f\) is unknown and we are optimizing a function w.r.t. the integral involving itself and its second order derivative. Then, this is the calculus of variations problem. Then, applying Green's first identity, we can arrive the same conclusion that
Implicit Smoothing Iteration
Let \(u^0 = f\), we can compute a new smoothed function \(u^{t+1}\) from the current solution \(u^t\) by solving
where \(id\) is the identity operator.
Discrete Laplacian
Note that we are doing graphics! So we will only need discrete approximations of id and Laplacian operators. Therefore, we need to produce some sparse Laplacian matrix \(L\in\mathbb R^{n\times n}\) for a mesh of \(n\) vertices.
Finite Element Derivation of the Discrete Laplacian
We want to approximate the Laplacian of a function \(\Delta u\). First, consider \(u\) as a piecewise-linear function represented by scalar values at each vertex, collected in \(\mathbf u\in \mathbb R^n\).
Any piecewise-linear function can be expressed as a sum of values at mesh vertices times corresponding piecewise-linear basis functions (hat functions, \(\varphi_i\))
By plugging the definition into smoothness energy above, we have
Therefore,
where
By defining \(\varphi_i\) as piecewise-linear hat functions, the values in the system matrix \(L_{ij}\) is uniquely determined by the geometry of the underlying mesh, known as cotangent weights.
First note that \(\nabla\varphi_i\) are constant on each triangle, and only nonzero on triangles incident on node \(i\), for such trianlge \(T_\alpha\), \(\nabla {\varphi_i}\) points perpendicularly from the opposite edge \(e_i\) with inverse magnitude equal to the height \(h\) of the triangle treating that opposite edge as base,
Now for neighboring nodes \(i,j\) connected by edge \(e_{ij}\). Then \(\nabla \varphi_i\) points toward node \(i\) perpendicular to \(e_i\) the same for \(\nabla \varphi_j\). Hence, call the angle formed between these two vectors \(\theta\), then
call \(a_ij = \pi-\theta\) the angle between \(e_i\) and \(e_j\), then
Thereforem \(\frac{\|e_j\|}{2A}\frac{\|e_i\|}{2A}\cos\theta = -\frac{\|e_j\|}{2A}\frac{\|e_i\|}{2A}\cos a_{ij}\), so that
Then, we can replace \(\|e_i\| = \frac{h_j}{\sin a_{ij}}\),
Similarly, inside the other triangle \(T_\beta\) incident on nodes \(i,j\) with angle \(\beta_{ij}\), we have
Then, go back to the integral over area,
Mass Matrix
Treated as an operator, the Laplacian matrix \(L\) compute the local integral of the Laplacian of \(u\). In the energy based formulation this is not an issue. If we used a similar FEM derivation for the data term we should get another sparse matrix \(M\in\mathbb R^{n\times n}\)
This matrix \(M\) is often diagonalized or lumped into a diagonal matrix, even in the context of FEM.
Replacing every thing with discrete case, we have
However, this equation is had to solve due to the singularity, multiply both sides by \(M\) gives a better
Now the system matrix \(A=M+\lambda L\) is symmetric and using Cholesky factorization we can solve with it.
Laplace Operator is Intrinsic
Note that \(\cot\) of a triangle only depends on the edge length, we do not need to know where vertices are actually positioned in space or even which dimension the mesh is living in. Also, applying transformations to a shape that does not change lengths, will have no effect on the Laplacian.
Cotangent as a function of only edge length
Given a triangle \(abc\) as shown below,
Note that \(A = \frac12 ah_a\), where \(h_a\) is the height perpendicular to \(a\), hence \(h_a = b\sin C\), so that
By Heron's formula
By law of cosines
Therefore,
Solutions
Data Denoising
Our geometry of the domain is not changing, we only change the scalar function living upon it. Therefore, build our discrete Laplacian \(L\) and mass function \(M\) and apply above formula with a chosen \(\lambda\) parameter.
Geometric Smoothing
The geometry will change the Laplacian, hence also \(L,M\) in the discrete setting. Therefore, if signal \(u\) is replaced with the positions of points on the surface (say vertices \(V\) in discrete case), then the smoothing iteration update rule is non-linear if we write as
However, assuming small changes in \(V\) have a negligible effect on \(L, M\) then we can discretize explicitly by having \(L,M\) before the update