def SplitSave(self, p = 'TSD/Train/Images', wp = 'TSD/Train/Split'):
'''
#p: #Dir contains images to split
#wp: #Dir to write split images
'''
c = 0
if not os.path.exists(wp):
os.mkdir(wp)
pdl = np.random.choice([fni for fni in os.listdir(p) if fni.startswith('di')], 32, replace = False)
for i, fn in enumerate(pdl):
print('{:4d}/{:4d}:\t{:s}'.format(i + 1, len(pdl), fn))
#A = imread(os.path.join(p, fn))[0:-14, 1:-1]
#A = self.GetScreen()
#S = self.ts.DivideIntoSubimages(A).astype(np.uint8)
A = imread(os.path.join(p, fn))[0:-12, 4:-4, :]
S = self.ts.DivideIntoSubimages(A).astype(np.uint8)
for i, Si in enumerate(S):
imsave(os.path.join(wp, '{:03d}.png'.format(c)), Si)
c += 1
评论列表
文章目录