python - 任何建议调整仅由 0 和 1 组成的 3d 图像数组的大小?
问题描述
我想调整(缩小)脑肿瘤分割的地面真实 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 和最近模式。调整图像大小后,其中一些还可以,但有些则不行。您可以在上面的第一张和第二张图片中看到问题。肿瘤区域有许多在调整大小之前不存在的孔。第三张图似乎没有问题。
我在缩放功能中修改了一些选项,但没有找到合适的解决方案。请帮我解决这个问题。谢谢你。
解决方案
推荐阅读
- grafana - 将仪表板保存到 Grafana 中的物理文件夹
- json - 希望在 Json [松弛] 中将按钮与块集成
- java - Docker 容器显示没有端口,可以找到 IP 但需要同时连接到 Java 应用程序
- multithreading - 在 Julia 中使用多线程时,矩阵乘法速度较慢
- django - Django - 基于类的视图问题如何在同一模板中结合 DetailView 和 ListView
- angular - 如何在 HTML 中重叠表格单元格?
- autohotkey - 自动热键 | 正则表达式匹配()。我该怎么做?
- linked-list - leetcode实践:能找到sum方法返回负数的bug
- c# - '无法从程序集'Microsoft.Extensions.Primitives'中加载类型'Microsoft.Extensions.Primitives.InplaceStringBuilder'
- html - 相当于 IE 的“object-fit:cover”的 CSS 样式