Last active
September 1, 2016 01:31
-
-
Save jhh/dce53b919a60dc98a84b68dc4657a3ab to your computer and use it in GitHub Desktop.
Solution to exercise 1.
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 sys | |
import os | |
# usage: python ex_001.py path/to/image.jpg | |
imgPath = sys.argv[1] | |
if not os.path.isfile(imgPath): | |
print("Image file not found.") | |
sys.exit() | |
# read in the image | |
img = cv2.imread(imgPath) | |
# display the image and wait for key press | |
cv2.imshow('original', img) | |
cv2.waitKey(0) | |
# convert to grayscale and display | |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
cv2.imshow('grayscale', gray) | |
cv2.waitKey(0) | |
# apply a blue and display | |
blurred = cv2.blur(gray, (9, 9)) | |
cv2.imshow('blurred', blurred) | |
cv2.waitKey(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment