tomosipo.geometry.base_projection module
- class tomosipo.geometry.base_projection.ProjectionGeometry(shape=1)[source]
Bases:
objectA general base class for projection geometries
- property angles
The angles from which projections are acquired.
This property is specific to non-vector geometries.
- Returns:
A numpy array of shape with length num_angles containing the angles in radians.
- Return type:
np.array
- property corners
Returns a vector with the corners of each detector
- Returns:
np.array Array with shape (num_angles, 4, 3), describing the 4 corners of each detector in (Z, Y, X)-coordinates.
- Return type:
np.array
- property det_normal
The detector normal vectors of the geometry.
In tomosipo, the normal vector usually points “into” the detector and away from the source/object. It is orthogonal to the v and u vectors.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the normal vectors.
- Return type:
- property det_pos
The detector positions of the geometry.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the detector positions.
- Return type:
- property det_shape
The shape of the detector.
- Returns:
(int, int) A tuple describing the height and width of the detector in pixels.
- Return type:
np.array
- property det_size
The size of the detector.
This property is dangerous for vector geometries, because for vector geometries it is not guaranteed that the detector size is constant through time. If the detector size is not constant, this property raises a ValueError. Otherwise, it returns the detector size.
- Returns:
The absolute size of the detector in the v and the u direction.
- Return type:
(scalar, scalar)
- property det_sizes
The size of each detector.
- Returns:
np.array Array with shape (num_angles, 2) in v and u direction (height x width)
- Return type:
np.array
- property det_u
The detector u-vectors of the geometry.
The ‘u’ vector is usually the “sideways” pointing vector describing the distance from the (0, 0) to (0, 1) pixel.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the u vectors.
- Return type:
- property det_v
The detector v-vectors of the geometry.
The ‘v’ vector is usually the “upward” pointing vector describing the distance from the (0, 0) to (1, 0) pixel.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the v vectors.
- Return type:
- property is_cone
Is this geometry a cone-beam geometry?
- Returns:
- Return type:
- property is_parallel
Is this geometry a parallel-beam geometry?
- Returns:
- Return type:
- property is_vec
Is this a vector geometry?
A geometry can either be a vector geometry, like
ConeVectorGeometry, orParallelVectorGeometry, or it can be a parametrized geometry likeConeGeometryorParallelGeometry.- Returns:
- Return type:
- property lower_left_corner
Returns a vector with the positions of the lower-left corner the detector
- Returns:
np.array Array with shape (num_angles, 3), describing the position of the lower-left corner of each detector in (Z, Y, X)-coordinates.
- Return type:
np.array
- property num_angles
The number of angles in the projection geometry
- Returns:
The number of angles in the projection geometry.
- Return type:
integer
- property num_steps
The number of orientations in the geometry
This property equals num_angles and is provided so projection geometries and volume geometries share the same interface.
- Returns:
- Return type:
- project_point(point)[source]
Projects point onto detectors
This function projects onto the virtual detectors described by the projection geometry.
For each source-detector pair, this function returns
(detector_intersection_y, detector_intersection_x)
where the distance is from the detector origin (center) and the units are in detector pixels.
This function returns np.nan if the source-point ray is parallel to the detector plane.
This function projects onto the detector even if the ray is moving away from the detector instead of towards it, or if the detector is between the source and point instead of behind the point.
- Parameters:
point – A three-dimensional vector (preferably np.array)
- Returns:
np.array([[detector_intersection_y, detector_intersection_x], …..])
- Return type:
np.array (num_angles * 2)
- property ray_dir
The ray direction of the geometry.
This property is not supported on cone geometries.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the ray direction vectors.
- Return type:
- rescale_det(scale)[source]
Rescale detector pixels
Rescales detector pixels without changing the size of the detector.
- Parameters:
scale – int or (int, int) Indicates how many times to enlarge a detector pixel. Per convention, the first coordinate scales the pixels in the v coordinate, and the second coordinate scales the pixels in the u coordinate.
- Returns:
a rescaled geometry
- Return type:
ProjectionGeometry
- reshape(new_shape)[source]
Reshape detector pixels without changing detector size
- Parameters:
new_shape – int or (int, int) The new shape of the detector in pixels in v (height) and u (width) direction.
- Returns:
self
- Return type:
- property src_pos
The source positions of the geometry.
Not supported on parallel geometries.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the source positions.
- Return type:
- to_astra()[source]
Convert geometry to astra geometry
- Returns:
An astra representation of the current geometry.
- Return type:
dict
- to_vec()[source]
Return a vector geometry of the current geometry
- Returns:
- Return type:
- tomosipo.geometry.base_projection.is_cone(g)[source]
- tomosipo.geometry.base_projection.is_parallel(g)[source]
- tomosipo.geometry.base_projection.is_projection(g)[source]
Determine if a geometry is a projection geometry
A geometry object can be a volume geometry or a projection geometry.
- Parameters:
g – a geometry object
- Returns:
True if g is a projection geometry
- Return type:
bool