1

我在我的应用程序中加载了一个 .nii 文件。

def show(self):
    image = SimpleITK.ReadImage(file_name)
    t1 = SimpleITK.GetArrayFromImage(image)
    t2 = color.rgb2gray(t1[w.get()])
    print(w.get())
    print(t2.shape)
    plt.ion()
    fig = plt.figure()
    ax = fig.add_subplot(111)
    line1 = ax.imshow(t2, cmap='gray')

当我移动滑块并在新图中向我展示大脑切片时调用此函数。(应用程序的屏幕截图附在此处:[1]:https ://i.stack.imgur.com/vzDJt.png )

我需要更新相同的图形/情节,有可能吗?

4

1 回答 1

0

那应该可行,但我不会打电话ReadImageGetArrayFromImage每次show都会被打电话。您不希望每次小部件更改时都重新加载和转换图像。当应用程序启动时,做一次这些事情。

如果您查看 SimpleITK-Notebooks,这几乎就是图像在 Jupyter 笔记本中的显示方式。

http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/04_Image_Display.html

'inline display with matplotlib' 部分用于imshow显示图像。

于 2020-06-10T11:28:06.507 回答