2016-05-18 13 views

cevap

5

kolay yolu SimpleITK kullanmaktır. Pek çok python sürümü için çalışan . .mhd okuma için/bu kodu size bu z içeren bir numpy dizi verecektir SimpleITK

import skimage.io as io 
img = io.imread('file.mhd', plugin='simpleitk') 

yükledikten sonra daha da kolay olabilir skimage kullanma from kaggle

import SimpleITK as sitk 
import numpy as np 
''' 
This funciton reads a '.mhd' file using SimpleITK and return the image array, origin and spacing of the image. 
''' 

def load_itk(filename): 
    # Reads the image using SimpleITK 
    itkimage = sitk.ReadImage(filename) 

    # Convert the image to a numpy array first and then shuffle the dimensions to get axis in the order z,y,x 
    ct_scan = sitk.GetArrayFromImage(itkimage) 

    # Read the origin of the ct_scan, will be used to convert the coordinates from world to voxel and vice versa. 
    origin = np.array(list(reversed(itkimage.GetOrigin()))) 

    # Read the spacing along each dimension 
    spacing = np.array(list(reversed(itkimage.GetSpacing()))) 

    return ct_scan, origin, spacing 
+0

BTW, [this] (http://stackoverflow.com/questions/37989196/how-do-i-open-mhd-file-corresponding-to-a-raw-file-in-blender-3d-tool) soru aynı. Birisi onları birleştirebilir mi? – savfod

3

kullanabilirsiniz .raw, y, x sıralama.

İlgili konular