当前位置: 首页 > 网络知识

SimpleITK 获取二值图像bbox

时间:2026-01-27 08:40:17
1 sitk_ seg_ img = sitk . ReadImage( m ) 2 bbox =get_ bbox_ fr mask(sitk_ seg_ _img) 3 4 def get_bbox_fr_mask(bin_mask): 5 # One is : sitk.LabelShapeStatisticsImageFilter() 6 # Input: bin_mask 7 # Output: bbox<x,y,z, length, width, height> 8 # here, x y z > (R, A, S) when direction=(1,1,1) 9 # Note: for GetArrayFrImage , it is <z, y, x> 10 # Front idx = 1, background idx = 0 11 label_filter = sitk.LabelShapeStatisticsImageFilter() 12 label_filter.Execute(bin_mask) 13 bbox = label_filter.GetBoundingBox(1) 14 return bbox 15 16 17 def get_bbox_fr_volme_and_mask(sitk_seg_img): 18 # Another is : sitk.LabelStatisticsImageFilter() 19 # Input: <raw_img ,bin_mask> 20 # Output: bbox = <x_min, x_max, y_min, y_max, z_min, z_max> 21 # Note: for GetArrayFrImage , it is <z, y, x> 22 # Front idx = 1, background idx = 0 23 label_filter = sitk.LabelStatisticsImageFilter() 24 label_filter.Execute(sitk_seg_img, sitk_seg_img) 25 bbox = label_filter.GetBoundingBox(1) 26 return bbox
1 def get_bbox_fr_mask(self, bin_mask): 2 # One is : sitk.LabelShapeStatisticsImageFilter() 3 # Input: bin_mask 4 # Output: bbox<x,y,z, length, width, height> 5 # here, x y z > (R, A, S) when direction=(1,1,1) 6 # Note: for GetArrayFrImage , it is <z, y, x> 7 # Front idx = 1, background idx = 0 8 label_filter = sitk.LabelShapeStatisticsImageFilter() 9 label_filter.Execute(bin_mask) 10 bbox = label_filter.GetBoundingBox(1) 11 return bbox 12 13 def landmarkCanal(self): 14 canalBoneNode = slicer.util.getFirstNodeByClassByName("vtkMRMLLabelMapVolumeNode", self._canal_seg) 15 segbounds = np.zeros([6]) 16 canalBoneNode.GetBounds(segbounds) 17 print("segbounds \n", segbounds) 18 itkImagelabel = sitkUtils.PullVolumeFrSlicer(canalBoneNode) 19 itkImagelabel = sitkast(itkImagelabel, sitk.sitkUInt8) 20 bbox = self.get_bbox_fr_mask(itkImagelabel) 21 print("bbox: \n", bbox)



上一篇:如何在word中输入定义符号(即等号上面一个三角形)
下一篇:Qt Cannot retrieve debugging output报错 (无法获取调试输出.)
ITK
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素