我有一个标签,我想申请 4 个共同注册的图像,以获得每个标签的平均值。目前,我必须编写 4 次代码。
我目前的代码是
import SimpleITK as sitk
import numpy as np
label = sitk.ReadImage('segmentation.nii.gz')
image1 = sitk.ReadImage('image1.nii')
image2 = sitk.ReadImage('image2.nii')
image3 = sitk.ReadImage('image3.nii')
image4 = sitk.ReadImage('image4.nii')
labelstatsFilter = sitk.LabelStatisticsImageFilter()
labelstatsFilter.SetUseHistograms(True)
labelstatsFilter.Execute(image1, label)
labelstatsFilter.GetMean(1)
labelstatsFilter.Execute(image2, label)
labelstatsFilter.GetMean(1)
labelstatsFilter.Execute(image3, label)
labelstatsFilter.GetMean(1)
labelstatsFilter.Execute(image4, label)
labelstatsFilter.GetMean(1)