From 73988dcf78a176521109611d104bc54dea4c2ac6 Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 18 Oct 2022 01:49:29 +0530 Subject: [PATCH] Added Python script to convert Pictures into Sketch --- scripts/Pictures into Sketch/README.md | 10 ++++++++++ scripts/Pictures into Sketch/main.py | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 scripts/Pictures into Sketch/README.md create mode 100644 scripts/Pictures into Sketch/main.py diff --git a/scripts/Pictures into Sketch/README.md b/scripts/Pictures into Sketch/README.md new file mode 100644 index 0000000..7b3f4d6 --- /dev/null +++ b/scripts/Pictures into Sketch/README.md @@ -0,0 +1,10 @@ +This is a simple Python script to convert Pictures into Sketch + +## Usage + +```bash +# install xlwt +pip install requests +# run script +python main.py +``` diff --git a/scripts/Pictures into Sketch/main.py b/scripts/Pictures into Sketch/main.py new file mode 100644 index 0000000..7c16042 --- /dev/null +++ b/scripts/Pictures into Sketch/main.py @@ -0,0 +1,11 @@ +from turtle import done +import cv2 +img = input("Enter the name of image with file extension name that is in the same directory") +image = cv2.imread(img) +grey_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) +invert = cv2.bitwise_not(grey_img) +blur = cv2.GaussianBlur(invert, (21,21),0) +invertedblur = cv2.bitwise_not(blur) +sketch = cv2.divide(grey_img, invertedblur, scale=256.0) + +cv2.imwrite("sketch.png", sketch) \ No newline at end of file