Last active
January 5, 2021 14:06
-
-
Save CosmicTechie/09d7dbce6c075c110c07fbfa6c8671cd 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 cv2 | |
import numpy as np | |
def sketch(img): | |
image = cv2.imread(img) | |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
inverted_image = 255 - gray_image | |
blurred = cv2.GaussianBlur(inverted_image, (21, 21), 0) | |
inverted_blurred = 255 - blurred | |
pencil_sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0) | |
ps=input('Sketch Name with Extension for Saving it:') | |
stat=cv2.imwrite(ps,pencil_sketch) | |
sketch=cv2.imread(ps) | |
horizontal = np.concatenate((image, sketch), axis=1) | |
cv2.imshow("Original Vs Pencil Sketch", horizontal) | |
cv2.waitKey(0) | |
img=input("Enter the image with its extension: ") | |
sketch(img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment