打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SimpleITK计算dice系数及Hausdorff距离(python代码)_愿十四亿神州尽舜尧-CSDN博客

愿十四亿神州尽舜尧 2018-10-09 22:45:26 

 12129 
 收藏 29

分类专栏: 代码 文章标签: dice Hausdorff距离 SimpleITK

版权

做医学图像分割,需要对分割结果进行评价,常用的有dice系数和Hausdorff距离等,如何在python中用SimpleITK自带函数实现这一功能呢,代码如下:

# -*- coding: utf-8 -*-import numpy as npimport osimport SimpleITK as sitkdef file_name(file_dir):   L=[]path_list = os.listdir(file_dir)path_list.sort() #对读取的路径进行排序for filename in path_list:if 'nii' in filename:        L.append(os.path.join(filename))return Ldef computeQualityMeasures(lP,lT):quality=dict()labelPred=sitk.GetImageFromArray(lP, isVector=False)labelTrue=sitk.GetImageFromArray(lT, isVector=False)hausdorffcomputer=sitk.HausdorffDistanceImageFilter()hausdorffcomputer.Execute(labelTrue>0.5,labelPred>0.5)quality["avgHausdorff"]=hausdorffcomputer.GetAverageHausdorffDistance()quality["Hausdorff"]=hausdorffcomputer.GetHausdorffDistance()dicecomputer=sitk.LabelOverlapMeasuresImageFilter()dicecomputer.Execute(labelTrue>0.5,labelPred>0.5)quality["dice"]=dicecomputer.GetDiceCoefficient()return qualitygtpath = ''predpath = ''gtnames = file_name(gtpath)prednames = file_name(predpath)labels_num = np.zeros(len(prednames))NUM=[]P=[]for i in range(len(gtnames)):gt = sitk.ReadImage(gtpath + gtnames[i])pred = sitk.ReadImage(predpath + gtnames[i])quality = computeQualityMeasures(pred,gt)
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
对python读取CT医学图像的实例详解
我喜欢 Python,因为它可以帮助我回答小问题
手把手教你使用Python提取快递信息
2021年将主导Python的7大图像处理库
9个Python极简代码,拿走即用
Python|杨辉三角那点儿事
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服