1 数据量大的时候
通过对T91缩放0.8,0.9,0.7,1进行数据增强,步长12进行裁剪图像大小为12的高分辨率图像块,共得到101632张子图像。
import argparse
import PIL.Image as pil_image
from PIL import Image
import random
import os
def convert_rgb_to_y(img, dim_order='hwc'):
if dim_order == 'hwc':
return 16. + (64.738 * img[..., 0] + 129.057 * img[..., 1] + 25.064 * img[..., 2]) / 256.
else:
return 16. + (64.738 * img[0] + 129.057 * img[1] + 25.064 * img[2]) / 256.
def random_crop(image, crop_shape):
nw = random.randint(0, image.size[0] - crop_shape[0])
nh = random.randint(0, image.size[1] - crop_shape[1])
image_crop = image.crop((nh, nw, nh + crop_shape[0], nw + crop_shape[1]))
return image_crop
def dataset(args):
flip = [0]
count = 0
pathlist = os.listdir(args.input_path)
if not os.path.exists(args.output_path):