Created
October 24, 2020 03:02
-
-
Save ehzawad/a1dbdc41a78e24108e89dec36c540831 to your computer and use it in GitHub Desktop.
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 math | |
import sys | |
from PIL import Image, ImageFilter | |
# ensure correct usage | |
if len(sys.argv) != 2: | |
sys.exit("Usage: Python3 edge_detection.py imagefilename") | |
# open image | |
image = Image.open(sys.argv[1]).convert("RGB") | |
# filtered image according to edge detection kernel | |
filtered = image.filter(ImageFilter.Kernel( | |
size=(3, 3), | |
kernel=[-1, -1, -1, -1, 8, -1, -1, -1, -1], | |
scale=1 | |
)) | |
# show resulting image | |
filtered.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment