使用python打开mrc格式图像

时间:2012-03-29 13:55:01

标签: image

import numpy as np
import Image
im=Image.open("C:\Users\jhon\Pictures\newtry\101201x0.mrc",)
newArr = numpy.fromfromstring(im.tostring(),numpy.uint8)
newArr = numpy.reshape(newArr,im.size)`

我从翻译中得到了这个,如果你们有人知道我是python的新手 感谢

IOError: [Errno 22] invalid mode ('rb') or filename: 'C:\\Users\\xxx\\Pictures\201x0.mrc'
File "C:\Users\jhon\try.py", line 18, in <module>
im=Image.open("C:\Users\xxx\Pictures\newtry\101201x0.mrc")
File "C:\EMAN2\python\Python27\Lib\site-packages\PIL\Image.py", line 1952, in open
fp = __builtin__.open(fp,'rb')

1 个答案:

答案 0 :(得分:0)

你可以安装和使用EMAN2,打开mrc文件的代码非常简单:

from EMAN2 import *
img = EMData("testOK.mrc", 0)
img.write_image("copy.mrc") #write a copy of the image on the disk

img.read_image("testOK2.mrc", 0)
img.write_image("copy2.mrc")  #write a copy of the image on the disk