boundingbox: Get the bounding box of an im3d volume or other compatible...

View source: R/im3d.R

boundingboxR Documentation

Get the bounding box of an im3d volume or other compatible object

Description

boundingbox.list is designed to be used on objects that contain 3D point information and for which xyzmatrix is defined.

boundingbox.shape3d is designed to be used on objects that contain 3D point information and inherit from rgl's shape3d class and for which xyzmatrix is defined. Presently this applies to mesh3d objects.

Set the bounding box of an im3d object

Usage

boundingbox(x, ...)

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

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

## S3 method for class 'list'
boundingbox(x, na.rm = FALSE, ...)

## S3 method for class 'neuron'
boundingbox(x, na.rm = FALSE, ...)

## S3 method for class 'shape3d'
boundingbox(x, na.rm = FALSE, ...)

## Default S3 method:
boundingbox(x, dims, input = c("boundingbox", "bounds"), ...)

boundingbox(x) <- value

Arguments

x

A vector or matrix specifying a bounding box, an im3d object, any object with base class list for which xyzmatrix can extract 3D points (e.g. neurons, surfaces etc), or, for boundingbox.character, a character vector specifying a file.

...

Additional arguments for methods

dims

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

na.rm

Whether to ignore NA points (default FALSE)

input

Whether x defines the boundingbox or bounds of the image (see details).

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.

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'.

Value

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

See Also

plot3d.boundingbox

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

Examples

boundingbox(c(x0=0,x1=10,y0=0,y1=20,z0=0,z1=30))
# bounding box for a neuron
boundingbox(Cell07PNs[[1]])

nat documentation built on April 6, 2022, 5:06 p.m.