cuboid¶
-
odl.phantom.geometric.
cuboid
(space, min_pt=None, max_pt=None)[source]¶ Rectangular cuboid.
- Parameters
- space
DiscretizedSpace
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 fromspace.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.
- space
- Returns
- phantom
DiscretizedSpaceElement
The generated cuboid phantom in
space
.
- phantom
Examples
If both
min_pt
andmax_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.]] )