matteo-ronchetti / torch-radon

Computational Tomography in PyTorch
https://torch-radon.readthedocs.io
GNU General Public License v3.0
219 stars 45 forks source link

How to conduct FBP with fan beam geometry? #33

Closed liuxxxxxx closed 2 years ago

liuxxxxxx commented 2 years ago

I did projection, filtering, and backprojection to a 2D 512×512 image but the reconstruction image is far more different from the original image. Here is the main codes:

 radon = RadonFanbeam(512, angles, 512, 512, det_count=739, det_spacing=1.0, clip_to_circle=False)
 img = torch.FloatTensor(img).to(torch.device('cuda')).unsqueeze(0).unsqueeze(0)
 our_fp = radon.forward(img)
 our_bp = radon.backprojection(radon.filter_sinogram(our_fp))

What's the right way to conduct FBP with fan beam geometry?Thanks a lot.

matteo-ronchetti commented 2 years ago

Which angles are you using?

liuxxxxxx commented 2 years ago

Which angles are you using?

Sorry. It's

angles = np.linspace(0, 2*np.pi, 180)
matteo-ronchetti commented 2 years ago

Can you please share the original image and the FPB reconstruction?

liuxxxxxx commented 2 years ago

Can you please share the original image and the FPB reconstruction?

original recon_fbpfan

liuxxxxxx commented 2 years ago

Can you please share the original image and the FPB reconstruction?

Here is the test code:

import torch
import imageio
import numpy as np
from torch_radon import RadonFanbeam

img = imageio.imread('original.png') / 65535.
angles = np.linspace(0, 2*np.pi, 180)
radon = RadonFanbeam(512, angles, 512, 512, det_count=739, det_spacing=1.0, clip_to_circle=False)
img = torch.FloatTensor(img).to(torch.device('cuda')).unsqueeze(0).unsqueeze(0)
p = radon.forward(img)
recon = radon.backprojection(radon.filter_sinogram(p))

imageio.imwrite('recon_fbpfan.png', (recon.cpu().squeeze(0).squeeze(0).numpy()*65535).astype(np.uint16))
matteo-ronchetti commented 2 years ago

I see. With your det_count and spacing the areas of the image "outside of the circle" appear only in a few projections and therefore cannot be reconstructed. To solve this issue you can increase the det_count (or spacing) so that det_count*spacing is large enough (I think that >= 1024 should be enough)

liuxxxxxx commented 2 years ago

I see. With your det_count and spacing the areas of the image "outside of the circle" appear only in a few projections and therefore cannot be reconstructed. To solve this issue you can increase the det_count (or spacing) so that det_count*spacing is large enough (I think that >= 1024 should be enough)

I increase the value of det_count and it worked! Thank you so much!