예제 #1
0
def main(src_path, dst_path, image_size):
    try:
        for file in image_list(src_path):
            _, name, ext = split_path(file)
            save = os.path.join(dst_path, name + ext)
            #save = os.path.join(dst_path, name+'a' + ext)
            print(save)
            resize_image_file(file, image_size, save)
            #rename(file,save)
    except IOError:
        pass  # You can always log it to logger
예제 #2
0
def rename(img_path, save_path):
    img_path = (norm_path(img_path))
    save_path = norm_path(save_path)

    save_dir, _, _ = split_path(save_path)
    if not os.path.exists(save_dir):
        os.makedirs(save_dir)

    # read image
    im = cv2.imread(img_path)
    cv2.imwrite(save_path[:-3] + 'png', im)
예제 #3
0
def main(data_dir, result_dir, image_size):
    try:
        for file in image_list(data_dir):
            _, name, ext = split_path(file)
            save = os.path.join(result_dir, name + ext)
            print(save)
            resize_image_file(file, image_size, save)

        make_dataset(data_dir, mask_dir, result_dir)

    except IOError:
        pass  # You can always log it to logger
예제 #4
0
def resize_image_file(img_path, image_size, save_path):
    img_path = (norm_path(img_path))
    save_path = norm_path(save_path)

    save_dir, _, _ = split_path(save_path)
    if not os.path.exists(save_dir):
        os.makedirs(save_dir)

    # read image
    im = cv2.imread(img_path)

    # resize image
    im = resize_image(im, image_size)

    # write image
    cv2.imwrite(save_path[:-3] + 'png', im)
예제 #5
0
def save_tensor_image(input, filename_list=None, path='temp'):

    if not os.path.isdir(path):
        os.makedirs(path)

    image_list = input.cpu().data.numpy()

    for i, image in enumerate(image_list):
        # get filename
        filename = get_increasing_filename() if filename_list is None else filename_list[i]

        #print(image.shape)

        image = np.transpose(image, axes=[1, 2, 0])
        #print(image.shape)
        _,file_dir,_ = split_path(filename)

        # save image

        scipy.misc.imsave(os.path.join(path, file_dir + '.png'), image.squeeze())
예제 #6
0
def resize_image_file(img_path, image_size, save_path):
    img_path = (norm_path(img_path))
    save_path = norm_path(save_path)

    save_dir, _, _ = split_path(save_path)
    if not os.path.exists(save_dir):
        os.makedirs(save_dir)

    # read image
    im = cv2.imread(img_path)

    # resize image
    im = resize_image(im, image_size)

    # # extract gammma image
    # greenpath = '/home/bong6/data/mrcnn_cer/classificationdataset_224 (copy)/train/green_type3'
    # if np.max(im[:, :, 0]) < 60 and np.max(im[:, :, 2]) < 60:
    #     if not os.path.exists(greenpath):
    #         os.makedirs(greenpath)
    #
    #     shutil.move(img_path, greenpath)
    # else:
    # write image
    cv2.imwrite(save_path[:-3] + 'png', im)