# Contours of a sphere of 10 mm radius
b.sphere <- vol.create (n.ijk = c (40, 40, 40), dxyz = c(1,1,1),
mid.pt = c (0, 0, 0), modality = "binary",
default.value = FALSE)
xyz <- expand.grid (-20:19, -20:19, -20:19)
R <- 10
Sphere.flag <- (xyz[, 1]^2 + xyz[, 2]^2 + xyz[, 3]^2) <= R^2
b.sphere$vol3D.data[Sphere.flag] <- TRUE
b.sphere$max.pixel <- TRUE
S.sphere <- struct.from.bin (b.sphere, roi.name = "sphere", external.only = TRUE)
str (S.sphere$roi.info)
Run the code above in your browser using DataLab