我对cv2.warpAffine
有问题。我想使用cv2.INTER_AREA
插值。但当我将图像从3kx3k调整到100x100时,它的工作原理与cv2.INTER_LINEAR
相同。
在docs中有一个类似于interpolation type的标志,但它不起作用=(
# 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())
而且图像是相等的,断言中没有任何异常。你知道吗
https://github.com/opencv/opencv/blob/174b4ce29d8e1ddbd899095c4b9fb4443444af45/modules/imgproc/src/imgwarp.cpp#L2600
仿射函数中有下一行代码
至于我,我分裂仿射变换旋转,移动和调整大小。并使用旋转和移动与线性插值。并使用
interpolation= cv2.INTER_AREA
插值调整大小。你知道吗相关问题 更多 >
编程相关推荐