预处理是肝脏分割重要的一步,良好的预处理过程可以有效的提高分割的准确度。此博文主要记录肝脏分割过程中常见的预处理方法及相关代码。
1、Kaggle LUNA16 competition preprocessing-tutorial
# 截取像素
image[image< -200] = -200 # 参考 H-DenseUNet 网络
image[image> 250] = 250
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)
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 条评论) |