Resize an image without distortion OpenCV

前端 未结 9 1992
日久生厌
日久生厌 2020-12-07 12:30

I am using python 3 and latest version of openCV. I am trying to resize an image using the resize function provided but after resizing the image is very distorted. Code :

9条回答
  •  猫巷女王i
    2020-12-07 13:10

    img = cv2.resize(img, (int(img.shape[1]/2), int(img.shape[0]/2)))
    

    will resize the image to half the original size. You can modify it for any other ratio. Note that the first argument passed to resize() is img.shape[1], and not img.shape[0]. This may be counter-intuitive. It is easy to overlook this reversal and get a very distorted picture.

提交回复
热议问题