我有一个问题cv2.warpAffine
。我想使用cv2.INTER_AREA
插值法。cv2.INTER_LINEAR
但它的工作原理与我将图像大小从 3kx3k 调整为 100x100 时的效果相同。在文档中有一个类似插值类型的标志,但它不起作用=(
# create random image
image = np.random.randint(0, 255, (3000, 3500, 3)).astype(np.uint8)
pts1 = np.float32([[0,0],[3000, 3500],[0,3500]])
t_size = 100
pts2 = np.float32([[5,12],[t_size + 20,t_size + 10],[0,t_size-50]])
# calculate transformation matrix
M = cv2.getAffineTransform(pts1,pts2)
# warp with different flags
image_linear = cv2.warpAffine(image, M, (t_size, t_size), flags = cv2.INTER_LINEAR)
image_area = cv2.warpAffine(image, M, (t_size, t_size), flags = cv2.INTER_AREA)
assert((image_linear == image_area).all())
Run Code Online (Sandbox Code Playgroud)
和image是平等的,assert也不例外。