def load_image(data, tar_size=(2048, 2048)): image = prep.imread(data.image) label = prep.imread(data.label, c=0) vessel = prep.imread(data.vessel, c=0) if image.shape[:2] != tar_size: image = prep.resize_image(image, tar_size=tar_size) if label.shape[:2] != tar_size: label = prep.resize_image(label, tar_size=tar_size) if vessel.shape[:2] != tar_size: vessel = prep.resize_image(vessel, tar_size=tar_size) return image, label, vessel
def _transform_label_data(file_path): img = imread(file_path, c=0) if img.max() > 1: img = img.astype(np.float) / 255.0 label_img = np.ones(shape=(img.shape[0], img.shape[1], c.layer_num)) for i in range(c.layer_num): label_img[:, :, i] = (img == i).astype(np.float) return label_img
def clear_images(): image_dicts = libfi.getfiledicbyext(_c.model_image_dir, ext='jpg') label_dicts = libfi.getfiledicbyext(_c.model_label_dir, ext='png') for k, v in label_dicts.items(): label = prep.imread(v, 0) if np.sum(label) <= 1: os.remove(v) os.remove(image_dicts[k]) print(k) for k, v in image_dicts.items(): if k not in label_dicts: os.remove(v)
def _transform_image_data(file_path): img = imread(file_path) img = img.astype(np.float) / 255.0 return img