Пример #1
0
from LIBS.ImgPreprocess.my_labelme import convert_json_mask

convert_json_mask(
    '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/original/images',
    '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/original/masks')

from LIBS.ImgPreprocess.my_rop import resize_rop_dir

# (640,480)->(640,512), (1600,1200)->(640,512)
resize_rop_dir('/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/original',
               '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess')

from LIBS.ImgPreprocess.my_image_helper import resize_images_dir
resize_images_dir(
    source_dir='/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess',
    dest_dir='/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess384',
    convert_image_to_square=True,
    image_size=384)

import os
from LIBS.DataPreprocess.my_data import write_csv_img_seg

filename_csv = os.path.abspath('ROP.csv')
write_csv_img_seg(
    filename_csv,
    '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess384/images')

print('OK')
Пример #2
0
import os
import math
import json
import csv
from LIBS.ImgPreprocess.my_image_helper import resize_images_dir

do_preprocess = True

dir_original = '/media/ubuntu/data2/Fover_center/ROP/2020_11_4_patient_based/original/'
preprocess_image_size = 384
dir_preprocess = '/media/ubuntu/data2/Fover_center/ROP/2020_11_4_patient_based/preprocess384/'
dir_tmp = '/tmp2/ROP_dataset2/'

if do_preprocess:
    resize_images_dir(dir_original,
                      dir_preprocess,
                      convert_image_to_square=True,
                      image_size=preprocess_image_size)

filename_csv = os.path.join(os.path.abspath('.'),
                            'fovea_ROP_patient_based.csv')
if os.path.exists(filename_csv):
    os.remove(filename_csv)

with open(filename_csv, 'w', newline='') as csvfile:
    csv_writer = csv.writer(csvfile, delimiter=',')
    csv_writer.writerow(['images', 'x', 'y'])

    for dir_path, subpaths, files in os.walk(dir_original, False):
        for f in files:
            full_filename = os.path.join(dir_path, f)
            file_base, file_ext = os.path.splitext(full_filename)
Пример #3
0
                        '.BMP', '.PNG', '.JPEG', '.JPG', '.TIFF', '.TIF'
                ]:
                    continue

                image_file_mask = image_file.replace('.png', '_mask.png')
                csv_writer.writerow([image_file, image_file_mask])


if __name__ == '__main__':
    convert_image_mask_name(
        '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/original',
        '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/preprocess')

    from LIBS.ImgPreprocess.my_image_helper import resize_images_dir
    resize_images_dir(
        '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/preprocess',
        '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/preprocess512',
        image_size=512)

    resize_images_dir(
        '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/preprocess',
        '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/preprocess384',
        image_size=384)

    dir_preprocess = '/media/ubuntu/data2/BloodVesselsSegment_2020_1_20/preprocess512'
    csv_file = os.path.abspath(os.path.join(sys.path[0], 'BloodVessel.csv'))
    gen_csv(csv_file, dir_preprocess)

    from LIBS.DataPreprocess.my_data import split_csv_img_seg
    split_csv_img_seg(file_csv='BloodVessel.csv',
                      file_csv_train='BloodVessel_train.csv',
                      file_csv_valid='BloodVessel_valid.csv')
GEN_CSV = True

TRAIN_TYPE = 'ocular_surface'

from LIBS.ImgPreprocess.my_image_helper import resize_images_dir
dir_original = '/media/ubuntu/data1/眼底眼表其他'
dir_preprocess = '/media/ubuntu/data1/眼底眼表其他'

# dir_original ='/media/ubuntu/data1/眼底眼表其他/tmp/original'
# dir_preprocess ='/media/ubuntu/data1/眼底眼表其他/tmp/preprocess'
# dir_original = '/media/ubuntu/data2/无法归类/original'
# dir_preprocess = '/media/ubuntu/data2/无法归类/preprocess'

if DO_PREPROCESS:
    resize_images_dir(dir_original, dir_preprocess, imgsize=299)


if GEN_CSV:
    filename_csv = os.path.abspath(os.path.join(sys.path[0], "..",
                'datafiles', TRAIN_TYPE + '.csv'))

    dict_mapping = {'0.fundus': 0, '1.ocular_surface': 1, '2.other_images': 2}

    # 读取目录,根据目录名提取类别,生成.csv文件
    if os.path.exists(filename_csv):
        os.remove(filename_csv)

    my_data.write_csv_based_on_dir(filename_csv, dir_preprocess, dict_mapping, match_type='header')

    train_files, train_labels, valid_files, valid_labels = my_data.split_dataset(
Пример #5
0
        center_x = df.at[i, 'X-Coordinate']
        center_y = df.at[i, 'Y-Coordinate']

        img_fover = create_img_fover(filename_fover, center_x, center_y)

        filename_dest = filename_fover.replace(fover_dir, dest_dir)

        if not os.path.exists(os.path.dirname(filename_dest)):
            os.makedirs(os.path.dirname(filename_dest))

        print(filename_dest)
        cv2.imwrite(filename_dest, img_fover)


resize_images_dir('/home/ubuntu/Fover_center/DR0_4黄斑不准重新标注400/512', imgsize=512)

exit(0)

base_dir = '/home/ubuntu/Fover_center/DR0_4黄斑不准重新标注400/preprocess/original'

for dir_path, subpaths, files in os.walk(base_dir, False):
    for f in files:
        img_file_source = os.path.join(dir_path, f)

        filename, file_extension = os.path.splitext(img_file_source)

        if file_extension.upper() not in ['.BMP', '.PNG', '.JPG', '.JPEG', '.TIFF', '.TIF']:
            print('file ext name:', f)
            continue