How to do Resize of image in Opencv Python

 How to do Resize of image in Opencv Python








Code:

import cv2
import numpy as np
img = cv2.imread('input.jpg')
print(img.shape)
imgResize = cv2.resize(img,(300,200))
cv2.imshow('Resize image',imgResize)
cv2.waitKey(0)


Code Explanation:
  • First we will import cv2 and numpy module
  • Then we will read our image by using cv2.imread and store this image into a variable called img
  • Then we will see what is the actual Size of the image by tyiping img.shape 
    Note : img is the name in which our image is store
  • Then we will resize our image as per our requirements by using command cv2.resize
  • after that we will show our image by cv2.imshow
  • To save the image checkout this blog

Post a Comment

0 Comments