import random
import os
import os.path as osp
from PIL import Image
import numpy as np
dataset = np.genfromtxt('D:\\local_optimization\\uiuc\\all.txt', dtype=str)
for idx in dataset:
orignal = Image.open('D:\\local_optimization\\uiuc\\orignal\\'+idx+'.png')
orignal_size = orignal.size
gt = Image.open('D:\\local_optimization\\uiuc\\ps_gt\\'+idx+'.bmp')
setp = 25
x = 0
y = 0
w = 256
h = 256
while y*setp+h<orignal_size[1]:
while x*setp+w<orignal_size[0]:
orignal_region = orignal.crop((x*setp, y*setp, x*setp+w, y*setp+h))
orignal_region.save('D:\\crop\\' + idx + '_{loop}_{haha}.png'.format(loop=x*setp,haha=y*setp))
gt_region = gt.crop((x*setp, y*setp, x*setp+w, y*setp+h))
gt_region.save('D:\\crop\\' + idx + '_{loop}_{haha}.bmp'.format(loop=x*setp,haha=y*setp))
x=x+1
x=0
y=y+1
v.2