Search code examples
pythondata-conversionsimpleitk

From numpy array to a mhd file in python


I'm trying to convert a numpy array into a mhd file using SimpleITK.

Do you know if this is possible and if so, how to do it ?


Solution

  • Sure. Here ya go:

    import SimpleITK as sitk
    
    img = sitk.GetImageFromArray(np_array)
    
    sitk.WriteImage(img, "your_image.mhd")