matteo-ronchetti / torch-radon

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

reconstruction performance #6

Closed knxie closed 4 years ago

knxie commented 4 years ago

hello, when testing the torch-radon algorithm, I found a performance-related problem.

if I use radon()->radon.forward()->radon.filtered()->radon.backprojection(), the reconstructed image has a low PSNR performance (i.e. big MSE) compared to offical matlab code (the same setting).

For example, for a CT image, the reconstruction performance of torch-radon is 29.39dB, while that of matlab is nearly 40 dB. Obviously, this reconstruction is not so satisfactory due to low PSNR.

So, could you tell me how to boost the basic performance of torch-radon? (without adding cnn modules and training?) My goal is to obtain high-quality sinograms (projections).

Thanks! Appreciate for your help!

matteo-ronchetti commented 4 years ago

I'm investigating this issue, could you please share the code you are using so that I can reproduce your results?

knxie commented 4 years ago

I'm investigating this issue, could you please share the code you are using so that I can reproduce your results?

` n_angles = 180 img_size = 256 angles = np.linspace(0,2*np.pi, n_angles, endpoint=False) radon = Radon(img_size, angles)

img_gt = img_gt.cuda() % test torch-radon errors img_reversed = radon.filter_sinogram(radon.forward(img_gt)) img_reversed = radon.backprojection(img_reversed)*np.pi/n_angles img_reversed = torch.clamp(img_reversed,0,1) psnr_current, ssim_current = batch_PSNR_SSIM(img_gt, img_reversed) ` batch_PSNR_SSIM is for computing their PSNR.

matteo-ronchetti commented 4 years ago

There was a problem with the filtration done for FBP, now it should be fixed, I checked the accuracy against scipy's "iradon". Please reinstall the library and check if these changes fixed your problem.

When filtering the sinogram you should specify clip_to_circle=True inside Radon constructor. I've also incorporated scaling inside the filter_sinogram function, removing the need to do *np.pi/n_angles.

Please refer to the updated FBP example https://github.com/matteo-ronchetti/torch-radon/blob/master/examples/fbp.py

knxie commented 4 years ago

There was a problem with the filtration done for FBP, now it should be fixed, I checked the accuracy against scipy's "iradon". Please reinstall the library and check if these changes fixed your problem.

When filtering the sinogram you should specify clip_to_circle=True inside Radon constructor. I've also incorporated scaling inside the filter_sinogram function, removing the need to do *np.pi/n_angles.

Please refer to the updated FBP example https://github.com/matteo-ronchetti/torch-radon/blob/master/examples/fbp.py

Thanks. If the clip_to_circle=False could be used when filtering? There are images that require parts out of the circle.

matteo-ronchetti commented 4 years ago

I've updated the library, you should be able to work with images that have parts outside the circle by increasing the parameter det_count so that rays will hit the whole image also when rotated. In particular det_count = int(math.sqrt(2) * resolution + 0.5) should be enough.

matteo-ronchetti commented 4 years ago

@knxie Have you been able to try the new version of the library?