def read_img(imgname): img = cv2.imread(imgname) imgs = pr.Intensity(img) img_batch = pr.down_sample(imgs) img_batch = np.float64(img_batch) img_batch_norm = pr.contrast_normalization(img_batch) img_all = img_batch_norm.reshape([1, IMAGE_HEIGHT, IMAGE_WIDTH, 1]) return img_all
def read_img_lbl(imgname, lblname): img = cv2.imread(imgname) lbl = cv2.imread(lblname) imgs = pr.Intensity(img) lbls = np.dot(lbl[..., :3], [0.299, 0.587, 0.114]) // 255 lbls = np.uint8(lbls) img_batch = pr.down_sample(imgs) img_batch = np.float64(img_batch) lbl_batch = pr.down_sample(lbls) img_batch_norm = pr.contrast_normalization(img_batch) img_all = img_batch_norm.reshape([1, IMAGE_HEIGHT, IMAGE_WIDTH, 1]) lbl_all = lbl_batch.reshape([1, IMAGE_HEIGHT, IMAGE_WIDTH, 1]) return img_all, lbl_all