资源简介

修改后,输入图像可以是任何大小要求jpg格式,如果不是要修改resize文件,需要基于keras(这个很好装的),图像放入指定文件,然后运行就可以了,输出在test里面,输出图像改为输出血管结果图像,且只能应用于测试,亲测对一般眼底图像数据库分割效果都很好。有问题或不能运行戳我。

资源截图

代码片段和文件信息

#==========================================================
#
#  This prepare the hdf5 datasets of the DRIVE database
#
#============================================================

import os
import h5py
import numpy as np
from PIL import Image



def write_hdf5(arroutfile):
  with h5py.File(outfile“w“) as f:
    f.create_dataset(“image“ data=arr dtype=arr.dtype)


#------------Path of the images --------------------------------------------------------------
#train
#original_imgs_train = “./DRIVE/training/images/“
#groundTruth_imgs_train = “./DRIVE/training/1st_manual/“
#borderMasks_imgs_train = “./DRIVE/training/mask/“
#test
data_dir_name=‘shenyang‘
base_dir = ‘/home/cmcc/share-data-220/u_net/retina-unet-master-zsy/‘
original_imgs_test = base_dir+data_dir_name+“/test/images/0/“
#groundTruth_imgs_test = “./DRIVE/test/1st_manual/“
borderMasks_imgs_test = base_dir+data_dir_name+“/test/mask/0/“
#---------------------------------------------------------------------------------------------

Nimgs = 20
channels = 3
height = 584
width = 565
dataset_path =base_dir+data_dir_name+“_datasets_training_testing/0/“

def get_datasets(imgs_dirborderMasks_dirtrain_test=“null“):
#def get_datasets(imgs_dirgroundTruth_dirborderMasks_dirtrain_test=“null“):
    imgs = np.empty((Nimgsheightwidthchannels))
    #groundTruth = np.empty((Nimgsheightwidth))
    border_masks = np.empty((Nimgsheightwidth))
    for path subdirs files in os.walk(imgs_dir): #list all files directories in the path
        for i in range(len(files)):
            #original
            print “original image: “ +files[i]
            img = Image.open(imgs_dir+files[i])
            imgs[i] = np.asarray(img)
            #corresponding ground truth
            #groundTruth_name = files[i][0:2] + “_manual1.gif“
            #groundTruth_name = files[i][:-4] + “_manual1.gif“#zsychange
            #print “ground truth name: “ + groundTruth_name
            #g_truth = Image.open(groundTruth_dir + groundTruth_name)
            #groundTruth[i] = np.asarray(g_truth)
            #corresponding border masks
            border_masks_name = ““
            if train_test==“train“:
                #border_masks_name = files[i][0:2] + “_training_mask.gif“
                border_masks_name = files[i][:-4] + “_training_mask.gif“
            elif train_test==“test“:
                #border_masks_name = files[i][0:2] + “_test_mask.gif“
                border_masks_name = files[i][:-4] + “_test_mask.gif“
            else:
                print “specify if train or test!!“
                exit()
            print “border masks name: “ + border_masks_name
            b_mask = Image.open(borderMasks_dir + border_masks_name)
            border_masks[i] = np.asarray(b_mask)

    print “imgs max: “ +str(np.max(imgs))
    print “imgs min: “ +str(np.min(imgs))
    #assert(np.max(groundTruth)==255 and np.max(border_masks)==255)
    #assert(np.min(groundTruth)==0 and np.min(border_masks)==0)
    print “ground truth

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件         50  2017-08-24 03:39  retina-unet-master-change\.gitignore

     文件      56770  2017-10-13 17:54  retina-unet-master-change\lib\1013.docx

     文件      18884  2017-10-13 15:58  retina-unet-master-change\lib\extract_patches.py

     文件       3344  2017-08-24 03:39  retina-unet-master-change\lib\help_functions.py

     文件       3479  2017-08-24 03:39  retina-unet-master-change\lib\pre_processing.py

     文件      16147  2017-08-24 03:39  retina-unet-master-change\Readme.md

     文件     729790  2017-10-01 02:21  retina-unet-master-change\shenyang\test\oridata\0\01.jpg

     文件     729790  2017-10-01 02:21  retina-unet-master-change\shenyang\test\oridata\1\01.jpg

     文件       4588  2017-10-13 14:50  retina-unet-master-change\shenyang\test\zsy_prepare_datasets_shenyang_0.py

     文件       4588  2017-10-13 14:55  retina-unet-master-change\shenyang\test\zsy_prepare_datasets_shenyang_1.py

     文件       2385  2017-10-13 14:17  retina-unet-master-change\shenyang\test\zsy_resize_0.py

     文件       2384  2017-10-13 14:17  retina-unet-master-change\shenyang\test\zsy_resize_1.py

     文件      11109  2017-10-13 17:14  retina-unet-master-change\src\retinaNN_predict.py

     文件       8958  2017-10-13 15:02  retina-unet-master-change\src\retinaNN_training.py

     文件     379000  2017-08-24 03:39  retina-unet-master-change\STARE_results\im0139.png

     文件        329  2017-08-24 03:39  retina-unet-master-change\test\performances.txt

     文件       8220  2017-08-24 03:39  retina-unet-master-change\test\test_architecture.json

     文件    1918968  2017-08-24 03:39  retina-unet-master-change\test\test_best_weights.h5

     文件       1336  2017-08-24 03:39  retina-unet-master-change\test\test_configuration.txt

     文件    1918968  2017-08-24 03:39  retina-unet-master-change\test\test_last_weights.h5

     文件     102731  2017-08-24 03:39  retina-unet-master-change\test\test_model.png

     文件       1375  2017-10-13 17:48  retina-unet-master-change\zsy_configuration.txt

     文件       4588  2017-10-13 14:50  retina-unet-master-change\zsy_prepare_datasets_shenyang_0.py

     文件       4588  2017-10-13 14:55  retina-unet-master-change\zsy_prepare_datasets_shenyang_1.py

     文件       2385  2017-10-13 14:17  retina-unet-master-change\zsy_resize_0.py

     文件       2384  2017-10-13 14:17  retina-unet-master-change\zsy_resize_1.py

     文件       1263  2017-10-13 15:13  retina-unet-master-change\zsy_run_testing.py

     目录          0  2017-10-19 11:19  retina-unet-master-change\shenyang\test\images\0

     目录          0  2017-10-19 11:19  retina-unet-master-change\shenyang\test\images\1

     目录          0  2017-10-19 11:19  retina-unet-master-change\shenyang\test\mask\0

............此处省略16个文件信息

评论

共有 条评论