MLEM.py 567 B

123456789101112131415161718192021
  1. import numpy as np
  2. def MLEM(G, G1, sino, imold, nx, na, nb, R=None, beta=1e-3):
  3. sino1=G.dot(imold.ravel()).reshape(na,nb)
  4. sino2=sino.copy()
  5. sino2 /= sino1
  6. #G1=np.transpose(G)
  7. #im1=G1.dot(sino.ravel()).reshape(nx,nx)
  8. #add regularization
  9. if R==None:
  10. im1=G1.dot(sino2.ravel()).reshape(nx,nx)
  11. else:
  12. v0=G1.dot(sino2.ravel())
  13. v1=R.dot(imold.ravel())
  14. v1=[1+beta*x for x in v1]
  15. v1=v1.reshape(nx,nx)
  16. v2=[x/y for x,y in join(v0,v1)]
  17. im1=v2.reshape(nx,nx)
  18. im1 *= imold
  19. return im1