def convert_images(image_name, folder_type, label_of_images, allImages):
#load the image_name
epi_img = nib.load(image_name)
#gest the data from the image
epi_img_data = epi_img.get_data()
#getting the slices
print("Getting the slices")
index2 = np.array(epi_img_data[1], dtype=int)
std_image = epi_img.get_data()[:,:,45]
slice_1 = epi_img_data[:,:,45]
#plotting the slice that we care for
print("Plotting the slices")
plot = plt.imshow(slice_1, cmap="gray")
plt.axis('off')
plot.axes.get_xaxis().set_visible(False)
plot.axes.get_yaxis().set_visible(False)
if allImages == "1":
full_path = image_name + '.png'
else:
full_path = folder_type + '/' + label_of_images + '/' + image_name + '.png'
#sving it
print("Saving the slice")
#plt.savefig(full_path, bbox_inches='tight', pad_inches = 0)
matplotlib.image.imsave(full_path, std_image, cmap="gray")
createDB.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录