Skip to content

Commit

Permalink
Fix absorption mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Apr 12, 2024
1 parent 6f74166 commit 0daeca9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/radon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,10 @@ end
@inline function calc_deposit_value(value_in, weight, sinogram, i, iangle, i_z, icell, jcell, xnew, ynew, x_dist_rot, y_dist_rot, absorb_f, xold, yold, ray_intensity, μ_array)
distance = sqrt((xnew - xold)^2 + (ynew - yold) ^2)

@inbounds ray_intensity -= ray_intensity * (distance) * μ_array[icell, jcell, i_z] / 2
ray_intensity = max(ray_intensity, zero(typeof(ray_intensity)))

@inbounds f = exp(-distance * μ_array[icell, jcell, i_z])
ray_intensity *= f
value = value_in * weight * distance * ray_intensity
@inbounds ray_intensity -= ray_intensity * (distance) * μ_array[icell, jcell, i_z] / 2
ray_intensity = max(ray_intensity, zero(typeof(ray_intensity)))
return value, ray_intensity
end

Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ using Zygote
angles = range(0, 2π, 10)
arr1 = backproject(sinogram, angles, μ=0.1)
arr2 = backproject(sinogram, angles, μ=0.1 * ones((10, 10)))
@test all(.≈(arr1, arr2, rtol=0.08))
@test all(.≈(arr1, arr2, rtol=0.001))


array = zeros((16, 16,1))
arr1 = radon(array, angles, μ=0.1)
arr2 = radon(array, angles, μ=0.1 * ones((10, 10)))
@test all(.≈(arr1, arr2, rtol=0.09))
arr2 = radon(array, angles, μ=0.1 * ones((16, 16)))
@test all(.≈(arr1, arr2, rtol=0.001))

end

Expand Down

0 comments on commit 0daeca9

Please sign in to comment.