Learn R Programming

Rvcg (version 0.24)

vcgIsosurface: Create Isosurface from 3D-array

Description

Create Isosurface from 3D-array using Marching Cubes algorithm

Usage

vcgIsosurface(
  vol,
  threshold,
  from = NULL,
  to = NULL,
  spacing = NULL,
  origin = NULL,
  direction = NULL,
  IJK2RAS = diag(c(-1, -1, 1, 1)),
  as.int = FALSE
)

Value

returns a triangular mesh of class "mesh3d"

Arguments

vol

an integer valued 3D-array

threshold

threshold for creating the surface

from

numeric: the lower threshold of a range (overrides threshold)

to

numeric: the upper threshold of a range (overrides threshold)

spacing

numeric 3D-vector: specifies the voxel dimensons in x,y,z direction.

origin

numeric 3D-vector: origin of the original data set, will transpose the mesh onto that origin.

direction

a 3x3 direction matrix

IJK2RAS

4x4 IJK2RAS transformation matrix

as.int

logical: if TRUE, the array will be stored as integer (might decrease RAM usage)

Examples

Run this code
#this is the example from the package "misc3d"
x <- seq(-2,2,len=50)
g <- expand.grid(x = x, y = x, z = x)
v <- array(g$x^4 + g$y^4 + g$z^4, rep(length(x),3))
storage.mode(v) <- "integer"
if (FALSE) {
mesh <- vcgIsosurface(v,threshold=10)
require(rgl)
wire3d(mesh)
##now smooth it a little bit
wire3d(vcgSmooth(mesh,"HC",iteration=3),col=3)
}

Run the code above in your browser using DataLab