def resize_image(image, params={}):
if params.has_key('height') and params.has_key('width'):
if np.random.uniform() < params.get('resize_prob', 1.0):
interpolation_map = {
'LINEAR': cv2.INTER_LINEAR,
'AREA': cv2.INTER_AREA,
'NEAREST': cv2.INTER_NEAREST,
'CUBIC': cv2.INTER_CUBIC,
'LANCZOS4': cv2.INTER_LANCZOS4,
}
interp = interpolation_map[np.random.choice(params.get('interpolation', ['LINEAR']))]
image,_ = resize_image_by_warp(image, params['width'], params['height'], interp)
return image
评论列表
文章目录