DRR¶
nanodrr.drr
¶
DRR
¶
Digitally reconstructed radiograph (DRR) generator module.
Encapsulates the intrinsic camera parameters needed to cast rays from an
X-ray point source through a 3D volume. Once initialized, call forward
with a Subject and extrinsic pose to produce a synthetic radiograph.
The intrinsic parameters (k_inv, sdd, height, width) are stored as
buffers or attributes so they travel with the module across devices and are
included in state_dict.
| ATTRIBUTE | DESCRIPTION |
|---|---|
_intrinsic_params |
Set of parameter names that define the camera intrinsics.
|
| PARAMETER | DESCRIPTION |
|---|---|
k_inv
|
Inverse intrinsic camera matrix. Maps pixel coordinates to camera-space ray directions.
TYPE:
|
sdd
|
Source-to-detector distance, i.e., the distance from the X-ray point source to the imaging plane.
TYPE:
|
height
|
Output image height in pixels.
TYPE:
|
width
|
Output image width in pixels.
TYPE:
|
Source code in src/nanodrr/drr/drr.py
render
¶
render(
subject: Subject,
k_inv: Float[Tensor, "B 3 3"],
rt_inv: Float[Tensor, "B 4 4"],
sdd: Float[Tensor, B],
height: int,
width: int,
n_samples: int = 500,
align_corners: bool = True,
src: Float[Tensor, "B (H W) 3"] | None = None,
tgt: Float[Tensor, "B (H W) 3"] | None = None,
) -> Float[Tensor, "B C H W"]
Differentiable ray marching through a volume and optional labelmap.
Casts rays from an X-ray source through a 3D volume (Subject.image) and
integrates sampled intensities along each ray to produce a synthetic
radiograph. When the subject contains a multi-class labelmap (Subject.label),
the integration is performed per-structure, yielding one channel per class.
| PARAMETER | DESCRIPTION |
|---|---|
subject
|
The volume to render. Must contain
TYPE:
|
k_inv
|
Inverse intrinsic camera matrix. Maps pixel coordinates to camera-space ray directions.
TYPE:
|
rt_inv
|
Inverse extrinsic (world-to-camera) matrix. Transforms rays from camera space into world space.
TYPE:
|
sdd
|
Source-to-detector distance, i.e., the distance from the X-ray point source to the imaging plane.
TYPE:
|
height
|
Output image height in pixels.
TYPE:
|
width
|
Output image width in pixels.
TYPE:
|
n_samples
|
Number of samples to take along each ray. Higher values improve accuracy at the cost of memory and compute.
TYPE:
|
align_corners
|
If
TYPE:
|
src
|
Pre-computed ray source positions in world coordinates. If
TYPE:
|
tgt
|
Pre-computed ray target positions (detector pixel locations) in
world coordinates. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[Tensor, 'B C H W']
|
Rendered synthetic radiograph. Shape is |