Python 中值过滤器的 ITK Rehsape 错误

Python ITK Rehsape error with median Filter

我有以下问题。我有一个大小为 91x40x21 且充满浮点数的 numpy 数组,我想使用中值滤波器。不幸的是,当我试图将它转换回数组时,我得到了这个错误:

"cannot reshape array of size 76440 into shape (0,0,0)"

这是我的代码:

image_view = itk.GetImageViewFromArray(matrix.astype('float32'))
medianImage = itk.MedianImageFilter.New(image_view, Radius = 3)
matrix = itk.GetArrayViewFromImage(medianImage)

如果您显式更新并从图像中获取输出,那么一切都会正常:

matrix = np.random.random_integers(0,100,(10,6,8))
image_view = itk.GetImageViewFromArray(matrix.astype('Float32'))
medianImageFilter = itk.MedianImageFilter.New(image_view, Radius = 3)
medianImageFilter.Update() 
medianImage = medianImageFilter.GetOutput()
newMatrix = itk.GetArrayViewFromImage(medianImage)