不改变标签值/scipy.ndimage.interpolation 或 RegularGridInterpolator 的 3D 多类蒙版的重采样/插值

问题描述

我有一个 3D 蒙版体积 L,其中包含以下内容

print(L.shape)
(170,256,256)
print("L: ",np.unique(L))
L: [0 1 2 3 4 5 6 7 8]

enter image description here


我想对掩码进行下采样,然后将掩码上采样到其原始大小,保持标签值相同。
尝试失败->下采样:

from scipy.ndimage.interpolation import zoom
zL = zoom(L,(0.5,0.5,0.5),mode='nearest')
print("zL: ",np.unique(zL))
zL:  [-3 -2 -1  0  1  2  3  4  5  6  7  8  9 10]

enter image description here


这是改变标签值。 我曾尝试使用其他 mode 选项,例如 constant 和所有选项。但似乎都不起作用。

尝试成功->下采样: 另一方面:

dx = 2
dy = 2
dz = 2
if DOWNSAMPLE:
    L_down = L[::dx,::dy,::dz]
print("L_down: ",np.unique(L_down))
L_down:  [0 1 2 3 4 5 6 7 8]

似乎无需更改标签值即可工作。

enter image description here


尝试失败->上采样: 但是当用

恢复到原始大小时
zL = zoom(L_down,(2,2,2),mode='nearest')

没有用。 此外,如果有关于三线性插值等的任何其他细节,我们将不胜感激。
谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)