<jupyter_start><jupyter_text>How to use radon.py<jupyter_code>import torch
import matplotlib.pyplot as plt
import radon_transformation.radon as radon

# install scikit-image
!{sys.executable} -m pip install scikit-image

# for dataset
from skimage.data import shepp_logan_phantom<jupyter_output><jupyter_text>Load DataFirst load your data. In this example we simulate a dataset with batchsize 5. The device can be either "cpu" or "cuda". Please be away that calculations ont he gpu are much faster than on cpu.<jupyter_code>device = "cuda"
batchsize = 5

# load example image
image = shepp_logan_phantom()

# transform to tensor and simulate a dataset with batchsize 5
image = torch.tensor(image).float().to(device)
image = image[None, None].repeat(batchsize, 1, 1, 1)

plt.imshow(image[0,0].cpu())
plt.colorbar()
plt.title("Input Image")
plt.show()<jupyter_output><empty_output><jupyter_text>Apply Radon Transformation and FBPApply radon trasnformation and filtered backprojection. You can change the number of projection angles by changing the value in *n_angles*.<jupyter_code># setting
n_angles = 1000
image_size = image.shape[-1]

# get operators 
radon_op, fbp_op = radon.get_operators(n_angles=n_angles, image_size=image_size, circle=True, device=device)

# apply radon transformation
sino = radon_op(image)
plt.imshow(sino[0,0].cpu())
plt.colorbar()
plt.title("Sinogram")
plt.show()

# apply filtered backprojection
reconstructed = fbp_op(sino)
plt.imshow(reconstructed[0,0].cpu())
plt.colorbar()
plt.title("Reconstruction")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10553083280356007, 'fraction_numerical': 0.01080737444373808, 'mean_word_length': 6.5311004784688995, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '187206', 'license': 'MIT', 'n_tokens_mistral': 562, 'n_tokens_neox': 535, 'n_words': 147, 'path': 'example.ipynb', 'repo_name': 'drgHannah/Radon-Transformation', 'size': '1573'}