Created
May 31, 2022 22:45
-
-
Save Merwanski/eb15afbf471cf0fea1c2ba9348331902 to your computer and use it in GitHub Desktop.
read_image_resize_show
This file contains hidden or 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 necessary packages | |
| import numpy as np | |
| import cv2 | |
| # path to image | |
| path_to_image = "data/cv_image_000.jpg" | |
| # read the image with cv2 | |
| image = cv2.imread(path_to_image) | |
| print('Original Dimensions : ', image.shape) | |
| scale_percent = 60 # percent of original size | |
| width = int(image.shape[1] * scale_percent / 100) | |
| height = int(image.shape[0] * scale_percent / 100) | |
| dim = (width, height) | |
| # resize the image | |
| resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA) | |
| print('Resized Dimensions : ', resized.shape) | |
| # show the image | |
| cv2.imshow("Original image", image) | |
| cv2.imshow("Resized image", resized) | |
| cv2.waitKey(0) | |
| cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment