Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: integration with I agePhantoms.jl #17

Closed
jakubMitura14 opened this issue Oct 14, 2024 · 5 comments
Closed

Question: integration with I agePhantoms.jl #17

jakubMitura14 opened this issue Oct 14, 2024 · 5 comments

Comments

@jakubMitura14
Copy link

Hello is it possible to use RadonKA multithreaded radon function together with ImagePhantoms.jl - I tried and failed to do it for now but I suppose it needs to e possible

@roflmaostc
Copy link
Owner

Hi,

Can you be a bit more specific of what is going wrong?

julia> using ImagePhantoms, RadonKA

julia> RadonKA.radon(shepp_logan(256), range(0, 2π, 101)[begin:end-1])
255×100 view(::Array{Float32, 3}, :, :, 1) with eltype Float32:
   0.0        0.0        0.0         0.0          0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0          0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   5.77778    5.58013    0.550234    0.0           0.0        1.92066     6.51792
  40.8889    34.652     25.1935      6.76986     11.831     28.9122     37.7231
  61.3333    58.7827    51.6459     40.7494       45.9667    54.5784     58.7827
  76.4444    75.2596    70.9944     61.17         64.1726    72.5281     75.2596
  88.8889    87.858     83.4645     78.0828       80.8409    85.9205     89.1454
  99.5556    98.0333    94.7471     89.6404       91.5415    94.7471    100.739
 109.333    107.991    106.037     100.524      102.674    107.735     107.991
 118.222    116.675    114.826     109.999       111.503    117.004     116.675
 126.667    125.358    122.298     120.568       122.307    122.221     125.327
 116.782    118.603    122.647     123.697       123.094    120.637     116.684
 113.013    114.424    114.526     119.04        117.576    114.231     114.418
 112.058    111.821    113.554     114.132      114.048    115.158     111.821
 111.964    112.428    110.99      110.463       110.367    110.246     113.053
 112.733    112.416    113.496     113.963       113.882    113.236     113.53
                                                                      
  91.0578    92.1768    90.63       88.3542       88.1484    90.0605     91.4011
  88.7555    88.4724    89.6846     87.9236       86.9391    88.3929     88.4724
  86.0089    86.2748    85.7529     85.9974       85.8021    85.576      86.2747
  83.0267    82.9931    82.148      79.9364      79.4105    82.1835     83.6801
  81.1511    79.1536    79.2552     81.3883       80.8137    79.6647     80.399
  78.3689    77.1574    77.8874     76.2199       76.1994    77.1186     77.179
  76.0133    75.587     78.1137     76.1127       75.619     76.8486     75.587
  74.7289    77.5844    73.474      77.239        78.5249    75.4567     75.5422
  79.0889    79.454     80.7382     79.9397      78.037     79.8423     79.4634
  76.4444    75.2596    72.6388     64.4744       61.4672    71.0655     75.2596
  61.3333    58.7826    54.7458     46.4197       41.3176    51.8458     58.7826
  40.8889    37.8148    29.1489     12.4131        7.15272   25.4216     34.7568
   5.77778    6.5442     2.0182      0.0           0.0        0.635788    5.61027
   0.0        0.0        0.0         0.0          0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0          0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0
   0.0        0.0        0.0         0.0           0.0        0.0         0.0

@jakubMitura14
Copy link
Author

Thanks for response ! I try for example

using ImagePhantoms: cylinder
using ImageGeoms: ImageGeom, axesf
using RadonKA
using Sinograms: CtFanArc, CtFanFlat,CtFan # CtPar
using Unitful: cm
using Sinograms: rays

#get size of the generated image
spacing = (0.3,0.3,0.3)
# spacing = (0.3,0.3,0.3)
ig = ImageGeom( dims=(64,64,50), deltas = (spacing[1]cm,spacing[2]cm,spacing[3]cm))

# Define the parameters for the cylinder
center = (0.0, 0.0, 0.0)  # Center of the cylinder
size = (1.0, 1.0, 2.0)    # Size of the cylinder (radius_x, radius_y, height)
angle = 0.0               # Angle of the cylinder

# Create the cylinder
ob = cylinder(center[1]cm, center[2]cm, center[3]cm, size[1]cm, size[2]cm, size[3]cm, angle, 0.0, 0, 1.0f0)
p = (ns = 130, ds = 0.3cm, nt = 130, dt = 0.4cm, na = 200, dsd = 200cm, dod = 40cm)
rg = CtFanArc( ; p...)
rayss=collect(rays(rg))
proj_arc = RadonKA.radon(rayss, ob)

give error

MethodError: no method matching radon(::Array{…}, ::ImagePhantoms.Object3d{…})

Closest candidates are:
  radon(::AbstractArray{T, 3}, ::AbstractVector; geometry, μ) where T
   @ RadonKA ~/.julia/packages/RadonKA/FXHjL/src/radon.jl:123

Stacktrace:
 [1] top-level scope
   @ ~/projects/synthethic_tomo-main (1)/synthethic_tomo-main/src/simple_radon_example.jl:23
Some type information was truncated. Use `show(err)` to see complete types.

using Sinograms radon it works but Here I assume some transformation of rays is required ?

@roflmaostc
Copy link
Owner

Please have a look at the documentation:
radon expects as the first argument the array and as the second argument the angles.

If you need special orientation of the rays (such as fan beam), you need to manipulate that manually with the different geometries:

https://roflmaostc.github.io/RadonKA.jl/stable/functions/#RadonKA.RadonFlexibleCircle

@jakubMitura14
Copy link
Author

Thanks ! I will work with it

@roflmaostc
Copy link
Owner

I'll close this issue for now. If something is unclear, feel free to open :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants