def load_patient_images(patient_id, base_dir=None, wildcard="*.*", exclude_wildcards=[]):
if base_dir == None:
base_dir = settings.LUNA_16_TRAIN_DIR
src_dir = base_dir + patient_id + "/"
src_img_paths = glob.glob(src_dir + wildcard)
for exclude_wildcard in exclude_wildcards:
exclude_img_paths = glob.glob(src_dir + exclude_wildcard)
src_img_paths = [im for im in src_img_paths if im not in exclude_img_paths]
src_img_paths.sort()
images = [cv2.imread(img_path, cv2.IMREAD_GRAYSCALE) for img_path in src_img_paths]
images = [im.reshape((1, ) + im.shape) for im in images]
res = numpy.vstack(images)
return res
评论列表
文章目录