Created
March 8, 2021 09:17
-
-
Save yokeshrana/b2a7fea55a8b16371a988b7c224ae98c to your computer and use it in GitHub Desktop.
Resizing the images Cropping the images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
img = cv2.imread("Resources/lambo.PNG") | |
cv2.imshow("Image ", img) | |
print(img.shape) | |
''' | |
Resizing the image | |
''' | |
imgResizeinc = cv2.resize(img,(600,600)) | |
print(imgResizeinc.shape) | |
cv2.imshow("Resize Image Inc",imgResizeinc) | |
imgResizedec = cv2.resize(img,(300,300)) | |
print(imgResizedec.shape) | |
cv2.imshow("Resize Image Dec",imgResizedec) | |
''' | |
Cropping the image : | |
Since image is a matrix we can use the normal matrix operations to crop the image | |
''' | |
imgCrop = img[0:200,200:500] # start_height: end_height , start_width: end_width | |
cv2.imshow("Cropped Image",imgCrop) | |
cv2.waitKey(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment