MLEM.py 542 B

1234567891011121314151617181920
  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. sino /= sino1
  5. #G1=np.transpose(G)
  6. #im1=G1.dot(sino.ravel()).reshape(nx,nx)
  7. #add regularization
  8. if R==None:
  9. im1=G1.dot(sino.ravel()).reshape(nx,nx)
  10. else:
  11. v0=G1.dot(sino.ravel())
  12. v1=R.dot(imold.ravel())
  13. v1=[1+beta*x for x in v1]
  14. v1=v1.reshape(nx,nx)
  15. v2=[x/y for x,y in join(v0,v1)]
  16. im1=v2.reshape(nx,nx)
  17. im1 *= imold
  18. return im1