Created
July 21, 2021 14:25
-
-
Save xeldrago/748b7e3db7bdc2f18845f1161d2ae8b0 to your computer and use it in GitHub Desktop.
a piece of code to change your images to sketch, hafun
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 | |
image=cv2.imread("TheImage.jpg") | |
gray_image=cv2.cvtColor( image, cv2.COLOR_BGR2GRAY) | |
inverted = 255-gray_image | |
blur = cv2.GaussianBlur(inverted, (21, 21), 0) | |
invertedblur = 255-blur | |
sketch = cv2.divide(gray_image, invertedblur, scale=256.0) | |
cv2.imwrite("WhatYouWantSketched.png", sketch) | |
cv2.imshow("Image", sketch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment