def load_img(self, img_filename):
"""
Summary:
Load image from the filename. Default is to load in color if
possible.
Args:
img_name (string): string of the image name, relative to
the image directory.
Returns:
np array of float32: an image as a numpy array of float32
"""
if not img_filename.endswith('.jpg'):
img_filename = os.path.join(self.img_dir, img_filename + '.jpg')
else:
img_filename = os.path.join(self.img_dir, img_filename)
img = skimage.img_as_float(io.imread(
img_filename)).astype(np.float32)
if img.ndim == 2:
img = img[:, :, np.newaxis]
elif img.shape[2] == 4:
img = img[:, :, :3]
return img
评论列表
文章目录