我正在处理一个大脑分割项目,需要预处理我的MRI(来自BRATS2015)。我想看看我的3D图片的直方图。我的代码:
#-*- coding:utf-8 -*-
import SimpleITK as sitk
import numpy as np
from matplotlib import pyplot
import matplotlib.pyplot as plt
url = r'H:\myfile\VSD.Brain.XX.O.MR_T1.54525.mha'
image = sitk.ReadImage(url)
result = sitk.GetArrayFromImage(image)
print(type(result))
print(result.shape)
plt.figure('historgram')
result = result.flatten()
n, bins, patches = plt.hist(result, bins=256, normed=0, facecolor='red', alpha=0.75)
plt.show()
但它有些不对。我想这样:enter image description here
哦,我处理它。
#-*- coding:utf-8 -*-
import SimpleITK as sitk
import numpy as np
from matplotlib import pyplot
import matplotlib.pyplot as plt
url = r'H:\deepfortest\brats2015_train\HGG\brats_2013_pat0003_1\VSD.Brain.XX.O.MR_T1.54525.mha'
image = sitk.ReadImage(url)
result = sitk.GetArrayFromImage(image)
print(type(result))
print(result.shape)
plt.figure('historgram')
result = result.flatten()
n, bins, patches = plt.hist(result, bins=256, range= (1,result.max()),normed=0, facecolor='red', alpha=0.75,histtype = 'step')
plt.show()