Installing Library
pip3 install opencv-python
Importing Library:
import cv2
Read the image:
img = cv2.imread(‘Mountain.jpg’, 1)
Resize the image by pixels:
img2 = cv2.resize(img, (400,400))
Resize the image by percentage:
img3 = cv2.resize(img, (0, 0), fx=0.5, fy=0.5)
Rotate the image 90 degree counterclockwise :
img4 = cv2.rotate(img, cv2.ROTATE_90_COUNTERCLOCKWISE)
Rotate the image 90 degree clockwise :
img5 = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE)
Rotate the image 180 degree :
img6 = cv2.rotate(img, cv2.ROTATE_180)
Save the Image:
Show the Image:
cv2.imshow(‘Image’, img)
WaitKey:
cv2.waitKey(0)
Destroy all windows:
cv2.destroyAllWindows()