Skip to content

Commit e1a9d8f

Browse files
committed
Use cp.take
1 parent cefaf68 commit e1a9d8f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

httomolibgpu/prep/stripe.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,11 @@ def _rs_dead(sinogram, snr, size, norm=True):
314314
if len(listxmiss) > 0:
315315
ids = cp.searchsorted(listx, listxmiss)
316316
weights = (listxmiss - listx[ids - 1]) / (listx[ids] - listx[ids - 1])
317-
# direct interpolation without making an extra copy
318-
sinogram[:, listxmiss] = sinogram[:, listx[ids - 1]] + weights * (
319-
sinogram[:, listx[ids]] - sinogram[:, listx[ids - 1]]
320-
)
317+
left_vals = cp.take(sinogram, listx[ids - 1], axis=1)
318+
right_vals = cp.take(sinogram, listx[ids], axis=1)
319+
diff = right_vals - left_vals
320+
diff *= weights
321+
sinogram[:, listxmiss] = left_vals + diff
321322

322323
# Remove residual stripes
323324
if norm is True:

0 commit comments

Comments
 (0)