cv2.reszie(src, dsize[, dst[, fx[, fy[, interpolation]]]])
scr : 原图
dsize : resize的尺寸(h,w)
interpolation: 插值方法
img = cv2.imread("/home/chenrui/hardware/tree2.png")
print(img.shape)
img_resize = cv2.resize(img, (256,256), interpolation=cv2.INTER_CUBIC)#双线性插值
img_resize1 = cv2.resize(img, (256,256), interpolation=cv2.INTER_LINEAR)#
img_resize2 = cv2.resize(img, (256,256), interpolation=cv2.INTER_NEAREST)#最近邻插值
img_resize3 = cv2.resize(img, (256,256), interpolation=cv2.INTER_AREA)#最近邻插值
print(img_resize.shape)
cv2.imshow("img",img)
cv2.imshow("img_resize",img_resize)
cv2.imshow("img_resize1",img_resize1)
cv2.imshow("img_resize2",img_resize2)
cv2.imshow("img_resize3",img_resize3)
cv2.waitKey(0)
cv2.destroyAllWindows()
本文详细介绍了使用OpenCV进行图像缩放的方法,包括不同插值方式如双线性插值、最近邻插值等,并展示了如何通过调整尺寸参数来改变图像大小。
810

被折叠的 条评论
为什么被折叠?



