def __check_size(self, img):
'''
checks if the image accords to the minimum size requirements
Returns:
tuple (img, bool):
img: the original image if the image size was ok, a resized image otherwise
bool: flag indicating whether the image was resized
'''
if np.amin(img.shape[:2]) < self.min_image_width_height:
if np.amin(img.shape[:2]) == 0:
return None, False
scale = float(self.min_image_width_height+1)/float(np.amin(img.shape[:2]))
new_shape = (int(scale*img.shape[0]), int(scale*img.shape[1]))
new_img = resize(image=img, output_shape=new_shape)
return new_img, True
else:
return img, False
评论列表
文章目录