Set the bounding box of an im3d object

boundingbox(x, ...)

# S3 method for im3d
boundingbox(x, dims = dim(x), ...)

# S3 method for character
boundingbox(x, ...)

# S3 method for default
boundingbox(x, na.rm = FALSE, ...)

boundingbox(x) <- value

## Arguments

x

an im3d object or any object for which xyzmatrix can extract 3D points (e.g. neurons, surfaces etc), or, for boundingbox.character, a character vector specifying a file.

...

Additional arguments passed to methods, and eventually to makeboundingbox

dims

The number of voxels in each dimension when x is a BoundingBox matrix.

na.rm

Whether to ignore NA points (default FALSE)

value

The object which will provide the new boundingbox information. This can be be either an im3d object with a boundingbox or a vector or matrix defined according to boundingbox.default.

## Value

a matrix with 2 rows and 3 columns with class='boundingbox' or NULL when missing.

## Details

The bounding box is defined as the position of the voxels at the two opposite corners of the cuboid encompassing an image, when each voxel is assumed to have a single position (sometimes thought of as its centre) and no physical extent. When written as a vector it should look like: c(x0,x1,y0,y1,z0,z1). When written as a matrix it should look like: rbind(c(x0,y0,z0),c(x1,y1,z1)) where x0,y0,z0 is the position of the origin.

Note that there are two competing definitions for the physical extent of an image that are discussed e.g. http://teem.sourceforge.net/nrrd/format.html. The definition that makes most sense depends largely on whether you think of a pixel as a little square with some defined area (and therefore a voxel as a cube with some defined volume) or you take the view that you can only define with certainty the grid points at which image data was acquired. The first view implies a physical extent which we call the bounds=dim(x) * c(dx,dy,dz); the second is defined as BoundingBox=dim(x)-1 * c(dx,dy,dz) and assumes that the extent of the image is defined by a cuboid including the sample points at the extreme corner of the grid. Amira takes this second view and this is the one we favour given our background in microscopy. If you wish to convert a bounds type definition into an im3d BoundingBox, you should pass the argument input='bounds'.

boundingbox.default is designed to be used on objects that contain 3D point information. This includes any object for which an xyzmatrix method is defined including matrix or data.frame objects describing 3D points as well as specialised classes such as neuron, neuronlist, rgl mesh3d objects.

makeboundingbox, plot3d.boundingbox

Other im3d: as.im3d(), im3d-coords, im3d-io, im3d(), imexpand.grid(), imslice(), is.im3d(), mask(), origin(), projection(), threshold(), unmask(), voxdims()

## Examples

# bounding box for a neuron
boundingbox(Cell07PNs[[1]])
#>          [,1]      [,2]      [,3]
#> [1,] 186.8660  90.36325  88.20393
#> [2,] 289.5364 132.70932 157.29700
#> attr(,"class")
#> [1] "boundingbox"