create_all_slices.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Deep-Learning-para-diagnostico-a-partir-de-imagenes-Biomedicas 作者: pacocp 项目源码 文件源码
def convert_images(image_name, folder_type, label_of_images, allImages, slice_number):
    #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()[:,:,slice_number]
    slice_1 = epi_img_data[:,:,slice_number]
    #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 = folder_type + "/" + 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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号