def load_img(path, grayscale=False, resize=None, order=1):
# Load image
img = io.imread(path)
# Resize
# print('Desired resize: ' + str(resize))
if resize is not None:
img = skimage.transform.resize(img, resize, order=order,
preserve_range=True)
# print('Final resize: ' + str(img.shape))
# Color conversion
if len(img.shape)==2 and not grayscale:
img = gray2rgb(img)
elif len(img.shape)>2 and img.shape[2]==3 and grayscale:
img = rgb2gray(img)
# Return image
return img
评论列表
文章目录