def extract_data(filename, num_images):
"""Extract the images into a 4D tensor [image index, y, x, channels].
Values are rescaled from [0, 255] down to [-0.5, 0.5].
"""
imgs = []
for i in range(1, num_images + 1):
imageid = "satImage_%.3d" % i
image_filename = filename + imageid + ".png"
if os.path.isfile(image_filename):
print('Loading ' + image_filename)
img = mpimg.imread(image_filename)
imgs.append(img)
else:
print('File ' + image_filename + ' does not exist')
num_images = len(imgs)
img_patches = [img_crop(imgs[i], IMG_PATCH_SIZE, IMG_PATCH_SIZE) for i in range(num_images)]
data = [img_patches[i][j] for i in range(len(img_patches)) for j in range(len(img_patches[i]))]
return numpy.asarray(data)
# Assign a label to a patch v
评论列表
文章目录