加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

图像分割的评价指标及代码

(2018-01-26 16:13:53)
分类: 图像
来源 http://blog.csdn.net/yangyangyang20092010/article/details/51637073

强烈建议参考如下两篇文章

Performance measure characterization for evaluating neuroimage segmentation algorithms

Metrics for evaluating 3D medical imagesegmentation: analysis, selection, and tool

main function (输入图像SEG 和 GT 分别为算法分割结果图像、分割金标准图像。对于多类分割的图像,需要先取出SEG和GT中对应的各类,然后使用下述函数单独计算该类。):


 

  1. test all segmentation metric functions  
  2. SEG imread('0.png');  
  3. GT imread('1.png');  
  4.   
  5. binarize  
  6. SEG im2bw(SEG, 0.1);  
  7. GT im2bw(GT, 0.1);  
  8.   
  9. dr Dice_Ratio(SEG, GT)  
  10. hd Hausdorff_Dist(SEG, GT)  
  11. jaccard Jaccard_Index(SEG, GT)  
  12. apd Avg_PerpenDist(SEG, GT)  
  13. confm_index ConformityCoefficient(SEG, GT)  
  14. precision Precision(SEG, GT)  
  15. recall Recall(SEG, GT)  

  1. function dr Dice_Ratio(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     dice ratio  
  4.     dr 2*double(sum(uint8(SEG(:) GT(:)))) double(sum(uint8(SEG(:))) sum(uint8(GT(:))));  
  5. end 

  1. function hd Hausdorff_Dist(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     erode element  
  4.     cat(3, [0 0], [0 0], [0 0]);  
  5.     generate boundary  
  6.     Boundary_SEG logical(SEG) ~imerode(logical(SEG), s);  
  7.     Boundary_GT logical(GT) ~imerode(logical(GT), s);  
  8.     distance to nearest boundary point  
  9.     Dist_SEG bwdist(Boundary_SEG, 'euclidean');  
  10.     Dist_GT bwdist(Boundary_GT, 'euclidean');  
  11.     distance to another boundary  
  12.     min_S2G sort(Dist_GT( Boundary_SEG(:) ), 'ascend');  
  13.     min_G2S sort(Dist_SEG( Boundary_GT(:) ), 'ascend');  
  14.     hausdorff distance  
  15.     hd max(min_S2G(end), min_G2S(end));  
  16. end  


  1. function jaccard Jaccard_Index(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     jaccard index  
  4.     jaccard double(sum(uint8(SEG(:) GT(:)))) double(sum(uint8(SEG(:) GT(:))));  
  5. end 


  1. function apd Avg_PerpenDist(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     erode element  
  4.     cat(3, [0 0], [0 0], [0 0]);  
  5.     generate boundary  
  6.     Boundary_SEG logical(SEG) ~imerode(logical(SEG), s);  
  7.     Boundary_GT logical(GT) ~imerode(logical(GT), s);  
  8.     distance to nearest boundary point  
  9.     Dist_GT bwdist(Boundary_GT, 'euclidean');  
  10.     distance to another boundary  
  11.     min_S2G Dist_GT( Boundary_SEG(:) );  
  12.     average perpendicular distance from SEG to GT  
  13.     apd sum(min_S2G(:)) length(min_S2G(:));  
  14. end  

  1. function confm_index ConformityCoefficient(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     dice ratio  
  4.     dr 2*double(sum(uint8(SEG(:) GT(:)))) double(sum(uint8(SEG(:))) sum(uint8(GT(:))));  
  5.     conformity coefficient  
  6.     confm_index (3*dr 2) dr;  
  7. end  

  1. function precision Precision(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     precision  
  4.     precision double(sum(uint8(SEG(:) GT(:)))) double(sum(uint8(SEG(:))));  
  5. end 

  1. function recall Recall(SEG, GT)  
  2.     SEG, GT are the binary segmentation and ground truth areas, respectively.  
  3.     recall  
  4.     recall double(sum(uint8(SEG(:) GT(:)))) double(sum(uint8(GT(:))));  
  5. end 



0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有