Skip to content

Commit

Permalink
Fix projection dtype and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-T-McCann committed Oct 1, 2024
1 parent b271f98 commit cf403bf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scico/linop/xray/_xray.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class XRayTransform2D(LinearOperator):
accumulation of pixel values into bins (equivalently, makes the
linear operator sparse).
Warning: The default pixel spacing is :math:`\sqrt{2}/2` (rather
than 1) in order to satisfy the aforementioned spacing requirement.
`x0`, `dx`, and `y0` should be expressed in units such that the
detector spacing `dy` is 1.0.
"""
Expand All @@ -64,9 +67,11 @@ def __init__(
corresponds to summing columns, and an angle of pi/4
corresponds to summing along antidiagonals.
x0: (x, y) position of the corner of the pixel `im[0,0]`. By
default, `(-input_shape / 2, -input_shape / 2)`.
dx: Image pixel side length in x- and y-direction. Should be
<= 1.0 in each dimension. By default, [1.0, 1.0].
default, `(-input_shape * dx[0] / 2, -input_shape * dx[1] / 2)`.
dx: Image pixel side length in x- and y-direction. Must be
set so that the width of a projected pixel is never
larger than 1.0. By default, [:math:`\sqrt{2}/2`,
:math:`\sqrt{2}/2`].
y0: Location of the edge of the first detector bin. By
default, `-det_count / 2`
det_count: Number of elements in detector. If ``None``,
Expand Down Expand Up @@ -146,8 +151,11 @@ def _project(
# ignored, while inds < 0 wrap around. So we set inds < 0 to ny.
inds = jnp.where(inds >= 0, inds, ny)

# avoid incompatible types in the .add (scatter operation)
weights = weights.astype(im.dtype)

y = (
jnp.zeros((len(angles), ny))
jnp.zeros((len(angles), ny), dtype=im.dtype)
.at[jnp.arange(len(angles)).reshape(-1, 1, 1), inds]
.add(im * weights)
)
Expand Down

0 comments on commit cf403bf

Please sign in to comment.