MedicalVisualization
Gradient Calculation
← Iso Surface Shading | ● | Flat Vs Smooth Shading →
Flat Shading vs Goruraud Shading → 1 normal per face vs. 3 normals per vertex:
Where do we get the original normal for our shaded iso surfaces?
Trick: for each of the 3 normals at the 3 vertices of each extracted triangle we use the gradient vector, which is perpendicular to the iso surface!
The gradient vector is computed on a discrete grid by finite differences method.
- Gradient vector is written as so called Nabla Operator ∇
- Gradient = partial derivatives of the continuous scalar function f(x,y,z)
∇f=(dfdx,dfdy,dfdz)T
- Discrete derivatives via finite differences method
- forward differences method
- df(x)ds≈f(x+Δs)−f(x)Δs
- backward differences method
- df(x)ds≈f(x)−f(x−Δs)Δs
- central differences methods has better smoothness
- df(x)ds≈f(x+Δs)−f(x−Δs)2Δs
- forward differences method
Normal →n=∇f=(f(x+Δs,y,z)−f(x−Δs,y,z)2Δs,f(x,y+Δs,z)−f(x,y−Δs,z)2Δs,f(x,y,z+Δs)−f(x,y,z−Δs)2Δs)T
- Discrete derivation via central differences on the voxel grid
- df(x)ds≈f(i+1)−f(i−1)2
- At the grid boundaries forward resp. backward differences.
- Hint: even better smoothness than ∇ via central differences: Sobel Operator!