Skip to content

Instantly share code, notes, and snippets.

@g7uvw
Last active March 20, 2018 16:37
Show Gist options
  • Save g7uvw/1f5524b396d3b0c88c398af30f471235 to your computer and use it in GitHub Desktop.
Save g7uvw/1f5524b396d3b0c88c398af30f471235 to your computer and use it in GitHub Desktop.
Not quite working tomo recon from images
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from skimage.io import imread
from skimage.transform import radon, iradon
from scipy.ndimage import zoom
basename = "projection_"
extention = ".jpeg"
plt.figure(figsize=(15, 15.5))
plt.subplot(221)
projections = 0
cs_array = [[]]
for x in range(0, 50):
name = basename + str(x).zfill(4) + extention
print name
image = imread(name, as_grey=True)
image_data = np.asarray(image)
cs_array[x] = image_data[120]
#plt.plot(projections);
cs = Image.fromarray(cs_array)
plt.imshow(cs, cmap=plt.cm.Greys_r)
# gives this error
# File "tomo.py", line 30, in <module>
# cs_array[x] = image_data[120]
#IndexError: list assignment index out of range
@JohnMacrae
Copy link

JohnMacrae commented Mar 20, 2018

Maybe print x at line 22? Maybe adjust the loop for one image only and read the image data into another type of variable to see if it’s a problem with passing to the array?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment