医学图像肝脏分割(一)

阅读: 评论:0

医学图像肝脏分割(一)

医学图像肝脏分割(一)

    预处理是肝脏分割重要的一步,良好的预处理过程可以有效的提高分割的准确度。此博文主要记录肝脏分割过程中常见的预处理方法及相关代码。

一、标准的预处理过程

1、Kaggle LUNA16 competition preprocessing-tutorial

二、截取像素
# 截取像素
image[image< -200] = -200  # 参考 H-DenseUNet 网络
image[image> 250] = 250      
三、Dicom格式将ct值转化为标准的hu值
    def get_pixel_hu(scan):img = scan.pixel_arrayimg = img.astype(np.int16)      # Convert to Hounsfield units (HU)intercept = scan.RescaleInterceptslope = scan.RescaleSlope    if slope != 1:img = slope * img.astype(np.float64)img = img.astype(np.int16)img += np.int16(intercept)return np.array(img, dtype=np.int16)
四、CT图像窗宽窗位调整
def transform_ctdata(image, windowWidth, windowCenter, normal=False):"""注意,这个函数的self.image一定得是float类型的,否则就无效!return: trucated image according to window center and window width"""minWindow = float(windowCenter) - 0.5*float(windowWidth)newimg = (image - minWindow) / float(windowWidth)newimg[newimg < 0] = 0newimg[newimg > 1] = 1if not normal:newimg = (newimg * 255).astype('uint8')return newimg# set the window center and window width
seg_liver = iput_img >= 1
ct_liver = iput_img * seg_liver
liver_max = ct_liver.max()
liver_min = ct_liver.min()
liver_wide = liver_max - liver_min
liver_center = (liver_max + liver_min)/2      
liver_wl = transform_ctdata(iput_img, liver_wide, liver_center, normal=False)
四、直方图均衡化
# 直方图均衡化
img_equalize = cv.equalizeHist(liver_wl)
clahe = cv.createCLAHE(clipLimit=4.0, tileGridSize=(8, 8))
img_clahe = clahe.apply(img_equalize)
五、图像归一化
# 归一化
max_bound = image.max()
min_bound = image.min()
img = (image- min_bound) / (max_bound - min_bound)
六、提取目标切片

这个代码稍微复杂些,代码思路是:先找到标签为0的图像,并记录该图像的id,然后从raw数据集中去掉这些id对应的图像。

七、数据增强

1、imgaug库
(1)用于医学图像分割的数据增强方法 —— 标准 imgaug 库的使用方法
(2)数据增强库imgaug使用
(2)imgaug数据增强神器:增强器一览

【参考】
1、Python+OpenCV图像处理(八)—— 图像直方图
2、学习笔记|Pytorch使用教程08(transforms数据预处理方法(二))
3、python skimage图像处理(三)(重点推荐)

本文发布于:2024-02-04 07:40:23,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170702199053609.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:肝脏   图像   医学
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23