summaryrefslogtreecommitdiffstats
path: root/tests/python
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2019-03-29 16:01:02 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2019-09-25 14:10:08 +0200
commit15f53527e2f38e8eeb8bece79376b5e4686f3dd4 (patch)
tree70f91d342fbd6bb094ff19db05aa0e784b92bf02 /tests/python
parent35957b6ef72749cdc520ded67a0eb8cdfd7ea655 (diff)
downloadastra-15f53527e2f38e8eeb8bece79376b5e4686f3dd4.tar.gz
astra-15f53527e2f38e8eeb8bece79376b5e4686f3dd4.tar.bz2
astra-15f53527e2f38e8eeb8bece79376b5e4686f3dd4.tar.xz
astra-15f53527e2f38e8eeb8bece79376b5e4686f3dd4.zip
Adjust distance driven kernels to line integral scaling
Diffstat (limited to 'tests/python')
-rw-r--r--tests/python/test_line2d.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/python/test_line2d.py b/tests/python/test_line2d.py
index 5647053..3019277 100644
--- a/tests/python/test_line2d.py
+++ b/tests/python/test_line2d.py
@@ -516,21 +516,26 @@ class Test2DKernel(unittest.TestCase):
if DISPLAY and x > TOL:
display_mismatch(data, sinogram, a)
self.assertFalse(x > TOL)
- elif proj_type == 'distance_driven':
+ elif proj_type == 'distance_driven' and 'par' in type:
a = np.zeros(np.prod(astra.functions.geom_size(pg)), dtype=np.float32)
for i, (center, edge1, edge2) in enumerate(gen_lines(pg)):
- (xd, yd) = center[1] - center[0]
+ (src, det) = center
+ try:
+ detweight = pg['DetectorWidth']
+ except KeyError:
+ detweight = effective_detweight(src, det, pg['Vectors'][i//pg['DetectorCount'],4:6])
+ (xd, yd) = det - src
l = 0.0
if np.abs(xd) > np.abs(yd): # horizontal ray
y_seg = (ymin, ymax)
for j in range(rect_min[0], rect_max[0]):
x = origin[0] + (-0.5 * shape[0] + j + 0.5) * pixsize[0]
- l += intersect_ray_vertical_segment(edge1, edge2, x, y_seg) * pixsize[0]
+ l += intersect_ray_vertical_segment(edge1, edge2, x, y_seg) * pixsize[0] / detweight
else:
x_seg = (xmin, xmax)
for j in range(rect_min[1], rect_max[1]):
y = origin[1] + (+0.5 * shape[1] - j - 0.5) * pixsize[1]
- l += intersect_ray_horizontal_segment(edge1, edge2, y, x_seg) * pixsize[1]
+ l += intersect_ray_horizontal_segment(edge1, edge2, y, x_seg) * pixsize[1] / detweight
a[i] = l
a = a.reshape(astra.functions.geom_size(pg))
if not np.all(np.isfinite(a)):
@@ -578,6 +583,8 @@ class Test2DKernel(unittest.TestCase):
if DISPLAY and x > TOL:
display_mismatch(data, sinogram, a)
self.assertFalse(x > TOL)
+ else:
+ raise RuntimeError("Unsupported projector")
def multi_test(self, type, proj_type):
np.random.seed(seed)