我想调整(缩小)脑肿瘤分割的地面真实 3d 图像的大小。
以下是一些 gt + 大脑图像:
Gt 图像是 3d numpy 数组,仅包含 0 和 1 值(只有绿色体素和黑色体素,gt 图像中不包括大脑)。
def resize(img, shape, mode='nearest', orig_shape=None, order=3):
"""
Wrapper for scipy.ndimage.zoom suited for MRI images.
"""
if orig_shape == None: orig_shape = img.shape
assert len(shape) == 3, "Can not have more than 3 dimensions"
factors = (
shape[0]/orig_shape[0],
shape[1]/orig_shape[1],
shape[2]/orig_shape[2]
)
# Resize to the given shape
return zoom(img, factors, mode=mode, order=order)
# original shape = (150, 512, 512)
# desired shape = (64, 192, 160)
我使用了 scipy zoom,顺序为 3 和最近模式。调整图像大小后,其中一些还可以,但有些则不行。您可以在上面的第一张和第二张图片中看到问题。肿瘤区域有许多在调整大小之前不存在的孔。第三张图似乎没有问题。
我在缩放功能中修改了一些选项,但没有找到合适的解决方案。请帮我解决这个问题。谢谢你。