def get_images(images_directory, groundtruths_directory, num_images):
#
# DESCRIPTION
# Loads each training image and its ground truth and creates tensors [numImages, 400, 400, 3]
#
# INPUTS
# images_directory path to training images directory
# groundtruths_directory path to the groundtruth images directory
# num_images number of images to load
#
# OUTPUTS
# images, ground_truth two tensors
#
images = []
ground_truth = []
for i in num_images:
image_id = "satImage_%.3d" % i
image_filename = image_id + ".png"
image_path = images_directory + image_filename;
groundtruth_image_path = groundtruths_directory + image_filename;
if ((os.path.isfile(image_path))&(os.path.isfile(groundtruth_image_path))):
print ('Loading ' + image_filename)
loaded_image = mpimg.imread(image_path)
loaded_gt_image = mpimg.imread(groundtruth_image_path)
if ordering == "th":
loaded_image = np.rollaxis(loaded_image,2)
images.append(loaded_image)
ground_truth.append(loaded_gt_image)
else:
print ('File ' + image_path + ' does not exist')
return images, ground_truth
评论列表
文章目录