MCPcopy Create free account
hub / github.com/dek924/PerX2CT / buildTrainB

Function buildTrainB

data_preprocessing/ctxray_utils.py:69–89  ·  view source on GitHub ↗
(raw_root_path, save_root_path)

Source from the content-addressed store, hash-verified

67
68# build CycleGAN trainSet B
69def buildTrainB(raw_root_path, save_root_path):
70 BSize = 1000
71 files_list = os.listdir(raw_root_path)
72 if not os.path.exists(save_root_path):
73 os.makedirs(save_root_path)
74 tb = np.arange(0, len(files_list))
75 np.random.shuffle(tb)
76 start = time.time()
77 for i in range(0, BSize):
78 t0 = time.time()
79 imageName = files_list[tb[i]]
80 print('Begin {}/{}: {}'.format(i+1, BSize, imageName))
81 imagePath = os.path.join(raw_root_path, imageName)
82 image = cv2.imread(imagePath, 0)
83 image = cv2.resize(image, (320, 320))
84 savePath = os.path.join(save_root_path, imageName)
85 cv2.imwrite(savePath, image)
86 t1 = time.time()
87 print('End! Case time: {}'.format(t1-t0))
88 end = time.time()
89 print('Finlly! Total time of build TrainB: {}'.format(end-start))
90
91# resize all images in a directory
92def resize_to_standard(path):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected