本笔记来源于B站Up主: 有Li 的影像组学系列教学视频
本节(32)主要介绍: 使用SimpleITK进行N4偏置场校正
N4偏置场的定义和产生原因
MR scans often display intensity non-uniformities due to variations in the magnetic field. So, one part of an image might appear lighter or darker when visualized, solely because of variations in the magnetic field. The map of these variations is called the bias field. The bias field can cause problems for a classifier as the variations in signal intensity are not due to any anatomical differences.
代码实现
import SimpleITK as sitk
imagePath = 'C:/Users/RONG/Desktop/Images/001/Lung_image.nrrd'
input_image = sitk.ReadImage(imagePath)
mask_image = sitk.OtsuThreshold(input_image,0,1,200)
input_image = sitk.Cast(input_image, sitk.sitkFloat32)
corrector = sitk.N4BiasFieldCorrectionImageFilter()
output_image = corrector.Execute(input_image,mask_image)
output_image = sitk.Cast(output_image, sitk.sitkInt16)
sitk.WriteImage(output_image, 'C:/Users/RONG/Desktop/Images/001/Lung_N4.nii.gz')
sitk.WriteImage(mask_image, 'C:/Users/RONG/Desktop/Images/001/Lung_mask.nii.gz')
知识扩展
Otsu Thresholding