gen_LRbicx4.py 1.07 KB
Newer Older
Rayyyyy's avatar
Rayyyyy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import cv2
import argparse

parser = argparse.ArgumentParser('gen BSD/urban100 LRbicx4', add_help=False)
parser.add_argument('--file_name', default='', type=str, help='Name of image file')
args = parser.parse_args()


if __name__ == "__main__":
    root_path = './{}'.format(args.file_name)
    GT_images_path = os.path.join(root_path, 'GTmod4')
    LR_images_path = os.path.join(root_path, 'LRbicx4')

    for img_name in os.listdir(GT_images_path):

        img_path = os.path.join(GT_images_path, img_name)
        print("img_path", img_path)
        save_path = os.path.join(LR_images_path, img_name)
        img = cv2.imread(img_path)
        if img is None:
            print("empty!!!!!", img_path)
            continue
        resize_width = int(img.shape[1]/4)
        resize_height = int(img.shape[0]/4)
        print("original size {} resize size {}".format(img.shape, (resize_width, resize_height)))
        img_resize = cv2.resize(img, (resize_width, resize_height), interpolation = cv2.INTER_AREA)

        cv2.imwrite(save_path, img_resize)
    print("processing end.")