-
-
Save vanishinggradient/b08b55a79bef75c912168424ece6bae7 to your computer and use it in GitHub Desktop.
Python implementation of the Radon Transform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Radon Transform as described in Birkfellner, Wolfgang. Applied Medical Image Processing: A Basic Course. [p. 344] """ | |
from scipy import misc | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def discrete_radon_transform(image, steps): | |
R = np.zeros((steps, len(image)), dtype='float64') | |
for s in range(steps): | |
rotation = misc.imrotate(image, -s*180/steps).astype('float64') | |
R[:,s] = sum(rotation) | |
return R | |
# Read image as 64bit float gray scale | |
image = misc.imread('shepplogan.png', flatten=True).astype('float64') | |
radon = discrete_radon_transform(image, 220) | |
# Plot the original and the radon transformed image | |
plt.subplot(1, 2, 1), plt.imshow(image, cmap='gray') | |
plt.xticks([]), plt.yticks([]) | |
plt.subplot(1, 2, 2), plt.imshow(radon, cmap='gray') | |
plt.xticks([]), plt.yticks([]) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment