医疗图像ROI区域根据标注自动提取
Posted Mario cai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了医疗图像ROI区域根据标注自动提取相关的知识,希望对你有一定的参考价值。
import numpy as np
import torchio as tio
from torch.utils.data import DataLoader
import torch
import nibabel as nib
z=0
while z<999:
z = z+1
subject = tio.Subject(
chest_ct=tio.ScalarImage(fr'C:\\Users\\Admin\\Desktop\\EGFR total\\EGFRzhong\\new\\data1\\dataz.nii.gz'),
heart_mask=tio.LabelMap(fr'C:\\Users\\Admin\\Desktop\\EGFR total\\EGFRzhong\\new\\mask1\\maskz.nii.gz'),
)
subject.chest_ct.shape
transform = tio.CropOrPad(
# (96, 96, 96),
mask_name='heart_mask',
)
transformed = transform(subject)
transformed.chest_ct.shape
a = transformed.get_first_image()
a = a.numpy()
x = a[0]
print(a[0].shape)
img_t1 = nib.Nifti1Image(x, np.eye(4))
nib.save(img_t1, f'outputz.nii.gz') # 将之保存为nii查看
以上是关于医疗图像ROI区域根据标注自动提取的主要内容,如果未能解决你的问题,请参考以下文章
OpenCV-C++选择提取感兴趣区域(ROI区域)附用鼠标选取ROI区域的代码