mitk.BaseGeometry#
- class mitk.BaseGeometry#
Bases:
pybind11_objectSpatial geometry of a 3D object.
A
BaseGeometryties the discrete index space (voxel indices) of an image or data object to a continuous world coordinate system. It carries:An origin: world coordinates of the index
(0, 0, 0).A spacing: world distance between adjacent indices along each axis.
A direction cosine matrix: orientation of the index axes in world space.
Bounds: the index-space extent of the data.
BaseGeometryis abstract. The concrete subclasses bound here areGeometry3D,PlaneGeometry, andSlicedGeometry3D.- __init__(*args, **kwargs)#
Methods
__init__(*args, **kwargs)clamp_point(self, point)Clamp a world-space point to the geometry's bounding box.
enforce_spacing(self, spacing)Set spacing and rescale the index-to-world transform accordingly.
get_axis_vector(self, direction)Return the world-space vector along the given index axis.
get_corner_point(self, id)Return the world coordinates of one of the eight corners.
get_extent(self, direction)Return the index-space extent along the given axis.
get_extent_in_mm(self, direction)Return the world-space extent along the given axis.
index_to_world(*args, **kwargs)Overloaded function.
initialize(self)Reset to an identity geometry with empty bounds.
initialize_geometry(self, geometry)Copy origin, spacing, direction, and bounds from another geometry.
is_index_inside(self, index)Test whether an index-space point lies inside the geometry.
is_inside(self, point)Test whether a world-space point lies inside the geometry.
is_valid(self)Return True if the geometry is fully initialized and self-consistent.
set_extent_in_mm(self, direction, extent)Set the world-space extent along the given axis (preserves spacing).
set_identity(self)Reset the index-to-world transform to the identity matrix.
translate(self, vector)Translate the geometry in world space.
world_to_index(*args, **kwargs)Overloaded function.
Attributes
Index-space bounding box as a 6-element list.
World coordinates of the center of the bounding box as a
Point3D.Length of the bounding-box diagonal in world units.
DICOM Frame of Reference ID used to group geometries that share a coordinate system.
Whether this geometry is interpreted as an image geometry.
Modified-time of the index-to-world transform; useful for cache invalidation.
Modified-time of the geometry as a whole.
World coordinates of the index
(0, 0, 0)as aPoint3D.Voxel spacing in world units as a
Vector3D(sx, sy, sz).- property bounds#
Index-space bounding box as a 6-element list.
Layout:
[xmin, xmax, ymin, ymax, zmin, zmax]. Assigning a list of any other length raises an exception.
- clamp_point(self: mitk.BaseGeometry, point: mitk.Point3D) mitk.Point3D#
Clamp a world-space point to the geometry’s bounding box.
- Parameters:
point – Point in world coordinates.
- Returns:
The nearest point inside the bounding box.
- property diagonal_length#
Length of the bounding-box diagonal in world units.
- enforce_spacing(self: mitk.BaseGeometry, spacing: mitk.Vector3D) None#
Set spacing and rescale the index-to-world transform accordingly.
Equivalent to
SetSpacing(spacing, enforceSetSpacing=True): rather than storing the spacing as an independent value, the transform is rebuilt so that the requested spacing is preserved exactly when the matrix is re-decomposed.- Parameters:
spacing – New spacing as a
Vector3D.
- property frame_of_reference_id#
DICOM Frame of Reference ID used to group geometries that share a coordinate system.
- get_axis_vector(self: mitk.BaseGeometry, direction: SupportsInt) mitk.Vector3D#
Return the world-space vector along the given index axis.
- Parameters:
direction – Index axis (0 = x, 1 = y, 2 = z).
- Returns:
The axis vector as a
Vector3D, of lengthextent_in_mm.
- get_corner_point(self: mitk.BaseGeometry, id: SupportsInt) mitk.Point3D#
Return the world coordinates of one of the eight corners.
- Parameters:
id – Corner index in
[0, 7].
- get_extent(self: mitk.BaseGeometry, direction: SupportsInt) float#
Return the index-space extent along the given axis.
- Parameters:
direction – Index axis (0 = x, 1 = y, 2 = z).
- Returns:
Extent in voxels.
- get_extent_in_mm(self: mitk.BaseGeometry, direction: SupportsInt) float#
Return the world-space extent along the given axis.
- Parameters:
direction – Index axis (0 = x, 1 = y, 2 = z).
- Returns:
Extent in world units (typically millimeters).
- property image_geometry#
Whether this geometry is interpreted as an image geometry.
When True, world coordinates address voxel centers (corner-based addressing shifted by half a voxel); when False, world coordinates address voxel corners.
- index_to_world(*args, **kwargs)#
Overloaded function.
index_to_world(self: mitk.BaseGeometry, index: mitk.Point3D, world: mitk.Point3D) -> None
Convert an index-coordinate point to a world-coordinate point.
- Parameters:
index – Input point in index coordinates.
world – Output point in world coordinates (filled in by the call).
index_to_world(self: mitk.BaseGeometry, index: mitk.Vector3D, world: mitk.Vector3D) -> None
Convert an index-coordinate vector to a world-coordinate vector.
- Parameters:
index – Input vector in index coordinates.
world – Output vector in world coordinates (filled in by the call).
- property index_to_world_last_modified#
Modified-time of the index-to-world transform; useful for cache invalidation.
- initialize(self: mitk.BaseGeometry) None#
Reset to an identity geometry with empty bounds.
- initialize_geometry(self: mitk.BaseGeometry, geometry: mitk.BaseGeometry) None#
Copy origin, spacing, direction, and bounds from another geometry.
- Parameters:
geometry – Source geometry to copy from.
- is_index_inside(self: mitk.BaseGeometry, index: mitk.Point3D) bool#
Test whether an index-space point lies inside the geometry.
- Parameters:
index – Point in index coordinates as a
Point3D.- Returns:
True if the index is inside the bounding box.
- is_inside(self: mitk.BaseGeometry, point: mitk.Point3D) bool#
Test whether a world-space point lies inside the geometry.
- Parameters:
point – Point in world coordinates as a
Point3D.- Returns:
True if the point is inside the bounding box.
- is_valid(self: mitk.BaseGeometry) bool#
Return True if the geometry is fully initialized and self-consistent.
- property modified#
Modified-time of the geometry as a whole.
- set_extent_in_mm(self: mitk.BaseGeometry, direction: SupportsInt, extent: SupportsFloat) None#
Set the world-space extent along the given axis (preserves spacing).
- Parameters:
direction – Index axis (0 = x, 1 = y, 2 = z).
extent – New extent in world units.
- set_identity(self: mitk.BaseGeometry) None#
Reset the index-to-world transform to the identity matrix.
- translate(self: mitk.BaseGeometry, vector: mitk.Vector3D) None#
Translate the geometry in world space.
- Parameters:
vector – Translation vector as a
Vector3D.
- world_to_index(*args, **kwargs)#
Overloaded function.
world_to_index(self: mitk.BaseGeometry, world: mitk.Point3D, index: mitk.Point3D) -> None
Convert a world-coordinate point to an index-coordinate point.
- Parameters:
world – Input point in world coordinates.
index – Output point in index coordinates (filled in by the call).
world_to_index(self: mitk.BaseGeometry, world: mitk.Vector3D, index: mitk.Vector3D) -> None
Convert a world-coordinate vector to an index-coordinate vector.
- Parameters:
world – Input vector in world coordinates.
index – Output vector in index coordinates (filled in by the call).