Last active
March 22, 2023 09:40
-
-
Save EteimZ/4f95ba9b8cfaebdf54f0d461c7ccf367 to your computer and use it in GitHub Desktop.
Opencv example to load image
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 cv2 as cv | |
| import sys | |
| # load gray scale image by setting the flag argument to cv.IMREAD_GRAYSCALE | |
| img = cv.imread("img.jpg", cv.IMREAD_GRAYSCALE) | |
| if img is None: | |
| sys.exit("Could not read the image") | |
| cv.imshow("Display window", img) | |
| k = cv.waitKey(0) | |
| if k == ord('s'): | |
| cv.imwrite("gray_img.jpg", img) | |
| elif k == ord('x'): | |
| sys.exit("Exiting image") |
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 cv2 as cv | |
| import sys | |
| img = cv.imread("img.jpg") | |
| if img is None: | |
| sys.exit("Could not read the image") | |
| cv.imshow("Display window", img) | |
| k = cv.waitKey(0) | |
| if k == ord('s'): | |
| cv.imwrite("new_pic.jpg", img) | |
| elif k == ord('x'): | |
| sys.exit("Exiting image") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment