python cv2 resize图片
时间: 2023-07-07 09:43:39 浏览: 84
可以使用OpenCV中的resize函数来调整图像大小。resize函数的语法如下:
```
cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]])
```
其中,src是原始图像,dsize是输出图像的大小,fx和fy是水平和垂直方向的缩放因子,interpolation是插值方法,可以选择INTER_NEAREST、INTER_LINEAR、INTER_AREA、INTER_CUBIC、INTER_LANCZOS4等。
具体的代码如下:
```python
import cv2
img = cv2.imread('image.jpg')
resized_img = cv2.resize(img, (800, 600), interpolation=cv2.INTER_LINEAR)
cv2.imshow('Original Image', img)
cv2.imshow('Resized Image', resized_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
这段代码会将名为image.jpg的图像调整为800x600大小,并显示原始图像和调整后的图像。
阅读全文
相关推荐










