Skip to content

Instantly share code, notes, and snippets.

@xeldrago
Created July 21, 2021 14:25
Show Gist options
  • Save xeldrago/748b7e3db7bdc2f18845f1161d2ae8b0 to your computer and use it in GitHub Desktop.
Save xeldrago/748b7e3db7bdc2f18845f1161d2ae8b0 to your computer and use it in GitHub Desktop.
a piece of code to change your images to sketch, hafun
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