首页 > 解决方案 > 如何使用 SimpleITK 从 MR 图像中分割白质?

问题描述

谁能帮我理解下面的代码?最大的想法是识别 MR 图像(灰度)中的白质并用绿色突出显示它。但是我看不到这项工作是如何完成的,SimpleITK 的文档也不容易阅读。

import SimpleITK

# Step 1: segment white matter from MR image 'imgSmooth'
imgWhiteMatter = SimpleITK.ConnectedThreshold(image1 = imgSmooth,
                                              seedList = [(150,75)],
                                              lower = 130, upper = 190,
                                              replaceValue = 1
                                            )

# Step 2: manipulate 'imgSmooth' so as to prepare for the overlay
imgSmoothInt = SimpleITK.Cast(SimpleITK.RescaleIntensity(imgSmooth), 
                              imgWhiteMatter.GetPixelID()
                             )

# Step 3: overlay manipulated 'imgSmooth' with 'imgWhiteMatter'
imgHightlight = SimpleITK.LabelOverlay(imgSmoothInt, imgWhiteMatter))

我至少有这些问题:

  1. 白质在哪一步以绿色突出显示?还是自动决定的?
  2. 本教程SimpleITK.RescaleIntensity()将 RGB 转换为 0-255 范围,但“imgSmoothInt”的数组主要由 2 到 5.5 的数字组成,而“imgSmooth”的数组从 0 到 4。
  3. 做什么SimpleITK.Cast()
  4. imgWhiteMatter.GetPixelID()返回 1,但我不明白这意味着什么以及它在第 2 步中扮演的角色。它是否指定了一些内容以使“imgSmoothInt”与“imgWhiteMatter”兼容?

标签: pythonimage-processingimage-segmentationsimpleitk

解决方案


推荐阅读