Extract connected components from a 3D mask
Usage
conn_comp_3D(mask, connect = c("26-connect", "18-connect", "6-connect"))
Arguments
- mask
a 3D binary array
- connect
the connectiivty constraint: "6-connect", "18-connect", or "26-connect"
Value
a two-element list of the connected components (cluster index
and cluster size
)
The first element index
is a 3D array containing the cluster index of the connected component for each voxel.
The second element size
is a 3D array consisting of the size of the connected component inhabited by each voxel.
Examples
dat <- array(as.logical(rnorm(10*10*10)>.5), c(10, 10, 10))
res1 <- conn_comp_3D(dat, connect="6-connect")
res2 <- conn_comp_3D(dat, connect="18-connect")
res3 <- conn_comp_3D(dat, connect="26-connect")