cuboid

odl.phantom.geometric.cuboid(space, min_pt=None, max_pt=None)[source]

Rectangular cuboid.

Parameters:
spaceDiscretizedSpace

Space in which the phantom should be created.

min_ptarray-like of shape (space.ndim,), optional

Lower left corner of the cuboid. If None is given, a quarter of the extent from space.min_pt towards the inside is chosen.

max_ptarray-like of shape (space.ndim,), optional

Upper right corner of the cuboid. If None is given, min_pt plus half the extent is chosen.

Returns:
phantomDiscretizedSpaceElement

The generated cuboid phantom in space.

Examples

If both min_pt and max_pt are omitted, the cuboid lies in the middle of the space domain and extends halfway towards all sides:

>>> space = odl.uniform_discr([0, 0], [1, 1], [4, 6])
>>> odl.phantom.cuboid(space)
uniform_discr([ 0.,  0.], [ 1.,  1.], (4, 6)).element(
    [[ 0.,  0.,  0.,  0.,  0.,  0.],
     [ 0.,  1.,  1.,  1.,  1.,  0.],
     [ 0.,  1.,  1.,  1.,  1.,  0.],
     [ 0.,  0.,  0.,  0.,  0.,  0.]]
)

By specifying the corners, the cuboid can be arbitrarily placed and scaled:

>>> odl.phantom.cuboid(space, [0.25, 0], [0.75, 0.5])
uniform_discr([ 0.,  0.], [ 1.,  1.], (4, 6)).element(
    [[ 0.,  0.,  0.,  0.,  0.,  0.],
     [ 1.,  1.,  1.,  0.,  0.,  0.],
     [ 1.,  1.,  1.,  0.,  0.,  0.],
     [ 0.,  0.,  0.,  0.,  0.,  0.]]
)