【发布时间】:2018-01-31 13:09:27
【问题描述】:
我有以下问题。我有一个充满浮点数的 3D numpy 数组,称为 scoreMatrix。现在我想在它上面使用 Itk 过滤器,比如阈值过滤器。这一般可以吗?我试图将 numpy 数组转换为 itk 图像,然后对其进行处理。还有其他方法吗?:
scoreMatrixItk = itk.GetImageViewFromArray(scoreMatrix)
itk.imwrite(scoreMatrixItk, "scoreMatrixItk")
PixelType = itk.UC
Dimension = 3
ImageType = itk.Image[PixelType, Dimension]
reader = itk.ImageFileReader[ImageType].New()
reader.SetFileName('scoreMatrixItk')
thresholdFilter = itk.OtsuMultipleThresholdsImageFilter[
ImageType,
ImageType].New()
thresholdFilter.SetInput(reader.GetOutput())
thresholdFilter.SetNumberOfHistogramBins(3)
thresholdFilter.SetNumberOfThresholds(2)
thresholdFilter.SetLabelOffset(4)
rescaler = itk.RescaleIntensityImageFilter[ImageType, ImageType].New()
rescaler.SetInput(thresholdFilter.GetOutput())
rescaler.SetOutputMinimum(0)
rescaler.SetOutputMaximum(255)
writer = itk.ImageFileWriter[ImageType].New()
writer.SetFileName('outputImage.tiff')
writer.SetInput(rescaler.GetOutput())
writer.Update()
但我收到错误:KeyError: "itkTemplate : No template [ >] for the itk::ImageFileWriter 类"
我需要注意一些事情吗?
【问题讨论】:
标签: python arrays numpy scipy itk