def imresize(img, scale):
"""Depending on if we scale the image up or down, we use an interpolation
technique as per OpenCV recommendation.
:param img:
3D numpy array of image.
:param scale:
float to scale image by in both axes.
"""
if scale > 1.0: # use cubic interpolation for upscale.
img = cv2.resize(img, None, interpolation=cv2.INTER_CUBIC,
fx=scale, fy=scale)
elif scale < 1.0: # area relation sampling for downscale.
img = cv2.resize(img, None, interpolation=cv2.INTER_AREA,
fx=scale, fy=scale)
return img
评论列表
文章目录