//目录

cv2.resize

import cv2

img = cv2.imread('0_116_99_355_0.jpg')


# 方法一:
# res = cv2.resize(img,None,fx=2,fy=2,interpolation=cv2.INTER_CUBIC)  #比例因子:fx=2,fy=2

# 方法二:
print(img.shape)
height, width = img.shape[:2]

res = cv2.resize(img, (129, 128), interpolation=cv2.INTER_CUBIC)  # dsize=(2*width,2*height) # 新的宽高
print(res.shape)

while (1):
    cv2.imshow('res', res)
    cv2.imshow('img', img)

    if cv2.waitKey(1) & 0XFF == 27:
        break
cv2.destroyWindow()

api:http://www.opencv.org.cn/opencvdoc/2.3.2/html/modules/imgproc/doc/geometric_transformations.html?highlight=resize#cv.Resize

tips: 要注意的是img.shape 返回高宽通道,resize 的时候是宽,高,插值方式。

posted @ 2018-12-10 10:40  小草的大树梦  阅读(4849)  评论(0编辑  收藏  举报