diff --git a/diffdrr/drr.py b/diffdrr/drr.py index f0e631339..24bedeaf8 100644 --- a/diffdrr/drr.py +++ b/diffdrr/drr.py @@ -189,6 +189,8 @@ def perspective_projection( x = torch.einsum("ij, bnj -> bni", self.detector.intrinsic, x) z = x[..., -1].unsqueeze(-1).clone() x = x / z + if self.detector.reverse_x_axis: + x[..., 1] = self.detector.width - x[..., 1] return x[..., :2] # %% ../notebooks/api/00_drr.ipynb 13 diff --git a/notebooks/api/00_drr.ipynb b/notebooks/api/00_drr.ipynb index 62889ea49..b8a3e0b8d 100644 --- a/notebooks/api/00_drr.ipynb +++ b/notebooks/api/00_drr.ipynb @@ -322,6 +322,8 @@ " x = torch.einsum(\"ij, bnj -> bni\", self.detector.intrinsic, x)\n", " z = x[..., -1].unsqueeze(-1).clone()\n", " x = x / z\n", + " if self.detector.reverse_x_axis:\n", + " x[..., 1] = self.detector.width - x[..., 1]\n", " return x[..., :2]" ] }, diff --git a/notebooks/tutorials/introduction.ipynb b/notebooks/tutorials/introduction.ipynb index f94edcf9f..523c0d9fb 100644 --- a/notebooks/tutorials/introduction.ipynb +++ b/notebooks/tutorials/introduction.ipynb @@ -424,8 +424,7 @@ "\n", "- `bone_attenuation_multiplier = 0` completely removes bones\n", "- `bone_attenuation_multiplier > 1` increases the contrast of bones relative to soft tissue\n", - "\n", - "This roughly simulates increasing the kVp of the X-ray imaging system." + " " ] }, {