【发布时间】:2017-11-22 07:13:43
【问题描述】:
我只是想保存没有填充和轴的图片。
下面是代码:
#-*- coding:utf-8 -*-
import SimpleITK as sitk
import numpy as np
import matplotlib.pyplot as plt
url = r"G:to\my\filename.mha"
path = r'F:\image\s.png'
image = sitk.ReadImage(url)
max_index = image.GetDepth()
max_width = image.GetWidth()
max_height = image.GetHeight()
print(max_index,max_width,max_height)
# As list of 2D numpy arrays which cannot be modified (no data copied)
xxx = sitk.GetArrayViewFromImage(image)[75,:,:]
zzz = plt.imshow(xxx,cmap = 'gray')
plt.savefig(path)
plt.show()
【问题讨论】:
-
如果您能以minimal working example 的身份提交我们可以运行以检查我们的解决方案并显示其效果,那就太好了。
-
@TomdeGeus,好的,我提交给 github.here:github.com/hei6775/example.git
-
那还是太复杂了!您可以使用一些随机数据来摆脱“SimpleITK”库。你的问题真的是关于 matplotlib 和 imshow。
-
@TomdeGeus没错。我正在努力解决问题
-
所以请在这里提交...编辑你的问题,只使用numpy作为matplotlib,那么我们真的可以提供帮助。
标签: matplotlib