利用Hessian矩阵对血管增强并且进行固定阈值分割

1.原始图像

2. 采用itk的Hessian矩阵进行血管增强

代码如下:

def vessleSegment(niipath):
    sigma_minimum = 0.2
    sigma_maximum = 3.
    number_of_sigma_steps = 8
    lowerThreshold = 40
    output_image = 'vessel.mha'
    input_image = itk.imread(niipath)
    # 1.采用itk的多尺度hessian矩阵进行血管增强
    ImageType = type(input_image)
    Dimension = input_image.GetImageDimension()
    HessianPixelType = itk.SymmetricSecondRankTensor[itk.D, Dimension]
    HessianImageType = itk.Image[HessianPixelType, Dimension]
    objectness_filter = itk.HessianToObjectnessMeasureImageFilter[HessianImageType, ImageType].New()
    objectness_filter.SetBrightObject(True)
    objectness_filter.SetScaleObjectnessMeasure(True)
    objectness_filter.SetAlpha(0.5)
    objectness_filter.SetBeta(1.0)
    objectness_filter.SetGamma(5.0)
    multi_scale_filter = itk.MultiScaleHessianBasedMeasureImageFilter[ImageType, HessianImageType, ImageType].New()
    multi_scale_filter.SetInput(input_image)
    multi_scale_filter.SetHessianToMeasureFilter(objectness_filter)
    multi_scale_filter.SetSigmaStepMethodToLogarithmic()
    multi_scale_filter.SetSigmaMinimum(sigma_minimum)
    multi_scale_filter.SetSigmaMaximum(sigma_maximum)
    multi_scale_filter.SetNumberOfSigmaSteps(number_of_sigma_steps)
    itk.imwrite(multi_scale_filter.GetOutput(), "step1.mha")

效果图如下:

3. 将增强后的血管归一化到0-255范围内

代码如下:

 # 2,将增强后的血管归一化到0-255范围
    OutputPixelType = itk.UC
    OutputImageType = itk.Image[OutputPixelType, Dimension]

    rescale_filter = itk.RescaleIntensityImageFilter[ImageType, OutputImageType].New()
    rescale_filter.SetInput(multi_scale_filter)
    itk.imwrite(rescale_filter.GetOutput(), "step2.mha")

效果图如下:

 4.对归一化的血管进行固定阈值分割

代码如下:

 # 3归一化的血管进行固定阈值分割
    thresholdFilter = itk.BinaryThresholdImageFilter[OutputImageType, OutputImageType].New()
    thresholdFilter.SetInput(rescale_filter.GetOutput())
    thresholdFilter.SetLowerThreshold(lowerThreshold)
    thresholdFilter.SetUpperThreshold(255)
    thresholdFilter.SetOutsideValue(0)
    thresholdFilter.SetInsideValue(255)
    itk.imwrite(thresholdFilter.GetOutput(), "step3.mha")

效果图如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值