| mris_smooth | R Documentation |
Smooths a closed triangular surface mesh by repeatedly replacing each vertex with the average of itself and its immediate neighbors (Laplacian/neighbor-averaging smoothing), optionally rescaling the surface back to its original area afterwards.
mris_smooth(
mesh,
niterations = 10L,
npasses = 1L,
rescale = FALSE,
verbose = FALSE
)
mesh |
triangular mesh of class |
niterations |
number of include-self 1-ring averaging rounds applied
to the vertex positions in each pass. Default |
npasses |
number of outer smoothing passes. Default |
rescale |
logical; whether to rescale the surface back to its original
area after each pass. Default |
verbose |
logical; print per-pass progress. Default |
For each of npasses passes, the algorithm:
Replaces each vertex position by the include-self mean of itself
and its 1-ring (directly-connected) neighbors, repeated
niterations times.
Recomputes vertex normals and total surface area.
Optionally rescales the surface back to its original area (only if
rescale = TRUE).
The smoothed surface as a 'mesh3d' object with vb,
it, and normals.
if (is_not_cran()) {
sphere <- vcg_sphere(sub_division = 4L)
# roughen the sphere slightly so smoothing has something to do
sphere$vb[1, ] <- sphere$vb[1, ] * (1 + 0.05 * rnorm(ncol(sphere$vb)))
# Fix defects
sphere <- vcg_fix_defects(sphere)
smoothed <- mris_smooth(sphere, niterations = 5L, verbose = TRUE)
plot_mesh_polygon(
list(sphere, smoothed),
alpha = c(0.3, 0.5),
col = list("gray", "red"),
main = "Gray: original; red: smoothed"
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.