Created
September 4, 2016 09:43
-
-
Save fubel/ad01878c5a08a57be9b8b80605ad1247 to your computer and use it in GitHub Desktop.
Python implementation of the Radon Transform
This file contains 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() |
@hakao32 imrotate is deprecated, you have to substitute it with sklearn's transform.rotate:
https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.imrotate.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code isnt working.