I just want to save the picture without the padding and the axis.
Below is the code:
#-*- 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()