View source: R/image-resample3d.R
resample_3d_volume | R Documentation |
'RAS'
) spaceLow-level implementation to sample a '3D' volume into given orientation and shape via a nearest-neighbor sampler.
resample_3d_volume(
x,
new_dim,
vox2ras_old,
vox2ras_new = vox2ras_old,
na_fill = NA
)
x |
image (volume) to be sampled: |
new_dim |
target dimension, integers of length 3 |
vox2ras_old |
from volume index (column-row-slice) to |
vox2ras_new |
the targeting transform from volume index to |
na_fill |
default numbers to fill if a pixel is out of bound; default is
|
A newly sampled volume that aligns with x
in the anatomical
'RAS'
coordinate system. The underlying storage mode is the same as
x
# up-sample and rotate image
x <- array(0, c(9, 9, 9))
x[4:6, 4:6, 4:6] <- 1
vox2ras <- matrix(nrow = 4, byrow = TRUE, c(
0.7071, -0.7071, 0, 0,
0.7071, 0.7071, 0, -5.5,
0, 0, 1, -4,
0, 0, 0, 1
))
new_vox2ras <- matrix(nrow = 4, byrow = TRUE, c(
0, 0.5, 0, -4,
0, 0, -0.5, 4,
0.5, 0, 0, -4,
0, 0, 0, 1
))
y <- resample_3d_volume(
x,
c(17, 17, 17),
vox2ras_old = vox2ras,
vox2ras_new = new_vox2ras,
na_fill = 0
)
image(y[9,,])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.