Skip to content

Commit 0b20782

Browse files
committed
Fix inverse projection
1 parent 831f76b commit 0b20782

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

diffdrr/drr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ def inverse_projection(
283283
pts: torch.Tensor,
284284
):
285285
"""Backproject points in pixel plane (2D) onto the image plane in world coordinates (3D)."""
286-
# pts = pts.flip(-1)
286+
pts[..., 1] = self.detector.height - pts[..., 1]
287287
if self.detector.reverse_x_axis:
288-
pts[..., 1] = self.detector.width - pts[..., 1]
288+
pts[..., 0] = self.detector.width - pts[..., 0]
289289
x = self.detector.sdd * torch.einsum(
290290
"ij, bnj -> bni",
291291
self.detector.intrinsic.inverse(),

notebooks/api/00_drr.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@
434434
" pts: torch.Tensor,\n",
435435
"):\n",
436436
" \"\"\"Backproject points in pixel plane (2D) onto the image plane in world coordinates (3D).\"\"\"\n",
437-
" # pts = pts.flip(-1)\n",
437+
" pts[..., 1] = self.detector.height - pts[..., 1]\n",
438438
" if self.detector.reverse_x_axis:\n",
439-
" pts[..., 1] = self.detector.width - pts[..., 1]\n",
439+
" pts[..., 0] = self.detector.width - pts[..., 0]\n",
440440
" x = self.detector.sdd * torch.einsum(\n",
441441
" \"ij, bnj -> bni\",\n",
442442
" self.detector.intrinsic.inverse(),\n",

0 commit comments

Comments
 (0)