Skip to content

Commit be96ec9

Browse files
authored
Incorporate alphaminimax in trilinear integral (#327)
* Incorporate alphaminimax in trilinear integral * Rerun trilinear tutorial
1 parent 7de8d20 commit be96ec9

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

diffdrr/renderers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def forward(
217217
.scatter_add_(1, channels.transpose(-1, -2), img.transpose(-1, -2))
218218
)
219219

220-
# Multiply by raylength and return the drr
220+
# Compute the line integral with the rectangular rule and return the DRR
221221
raylength = (target - source + self.eps).norm(dim=-1).unsqueeze(1)
222-
img *= raylength / n_points
222+
step_size = (alphamax - alphamin) / (n_points - 1)
223+
img *= raylength * step_size
223224
return img

notebooks/api/01_renderers.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
"\n",
279279
"Now, the rendering equation is\n",
280280
"\\begin{equation}\n",
281-
" E(R) = \\|\\mathbf p - \\mathbf s\\|_2\\frac{1}{M} \\sum_{m=1}^{M} \\mathbf V \\left[ \\mathbf s + \\alpha_m (\\mathbf p - \\mathbf s) \\right] \\,,\n",
281+
" E(R) = \\|\\mathbf p - \\mathbf s\\|_2\\frac{\\alpha_{\\max} - \\alpha_{\\min}}{M-1} \\sum_{m=1}^{M} \\mathbf V \\left[ \\mathbf s + \\alpha_m (\\mathbf p - \\mathbf s) \\right] \\,,\n",
282282
"\\end{equation}\n",
283283
"where $\\mathbf V[\\cdot]$ is the trilinear interpolation function and $M$ is the number of points sampled per ray."
284284
]
@@ -348,9 +348,10 @@
348348
" .scatter_add_(1, channels.transpose(-1, -2), img.transpose(-1, -2))\n",
349349
" )\n",
350350
"\n",
351-
" # Multiply by raylength and return the drr\n",
351+
" # Compute the line integral with the rectangular rule and return the DRR\n",
352352
" raylength = (target - source + self.eps).norm(dim=-1).unsqueeze(1)\n",
353-
" img *= raylength / n_points\n",
353+
" step_size = (alphamax - alphamin) / (n_points - 1)\n",
354+
" img *= raylength * step_size\n",
354355
" return img"
355356
]
356357
},

notebooks/tutorials/trilinear.ipynb

Lines changed: 24 additions & 24 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)