import skimage.io as io
from PIL import Image
import numpy as np
import nrrd
import os
from scipy import misc
imagelist = os.listdir('.')
imagelist = imagelist[:-1] #ignore the py code
for i in imagelist:
nrrd_data, nrrd_options = nrrd.read(i)
nrrd_data = 255*nrrd_data.astype('uint8')
nrrd_data = np.transpose(nrrd_data)
filename = 'image' +i[2:7]+'.tif' #make the name the same with the original images
io.imsave(filename,nrrd_data)
改文件需要放在待转化的.rrd文件的当前文件夹。
filename可能需要改。
tif可以替换成jpg
网友评论