使用ipython定义空的ITK图像

时间:2013-05-31 10:21:23

标签: python ipython ipython-notebook itk

我正试图在iPython笔记本上定义一个特定3D尺寸的空ITK图像,而我却坚持定义所谓的:

'itkIndex3' index

我已经为itk和vtk加载了所有python绑定,并定义了不同的类型(在这种情况下是一个大小为80且体素大小为0.5 mm的浮动三维图像),但我仍然无法填充它具有任何价值。这是代码,所以你可以看看:

# Tools for Biomedical Imaging
import nibabel as nib
import itk
import vtk

start = itk.Index[3]
size = itk.Size[3]
start.Fill(0)

-----------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/administrator/<ipython-input-63-8774101ef8fb> in <module>()
      1 start = itk.Index[3]
      2 size = itk.Size[3]
----> 3 start.Fill(0)

Fill() must be called with itkIndex3 instance as first argument (got int instance instead)

也许这是一个完全愚蠢的问题,但我真的很感谢有人在定义'填充'值时可能会出现错误。

提前致谢!!

-------------------------------------------------------------------
-------------------------------------------------------------------

嗨!我认为我能够用不同的方法解决问题,我将包含用于创建3D浮动图像的代码供所有人查看;)!

nii_PixelType = itk.F    # Read the image, also possible using nibabel
nii_ImageType = itk.Image[nii_PixelType, 3]

def CreateBaseAtlas(total_Size):

    # Created based on the code in:
    # http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter
    image = nii_ImageType.New()
    _start=[0,0,0]
    _size=[total_Size,total_Size,total_Size]
    _region = itk.ImageRegion._3(_start,_size)
    image.SetRegions(_region)
    image.Allocate()
    image.FillBuffer(0)   

    return image

我认为它不起作用的原因仅仅是因为我没有将它直接写成矢量。在ITK中,他们以不同的方式进行:http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter

0 个答案:

没有答案