Pencil Sketch of a photo
we disscuss all the steps regarding the project one by one below:
Since images are just arrays, we can easily do this programmatically using the divide function from the cv2 library in Python.
The only library we need for converting an image into a Pencil Sketch with Python is OpenCV library in Python.
import cv2
image = cv2.imread("/Atif2.jpg") cv2.imshow("orijinal-image", inverted_image) cv2.waitKey(0)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow("New Dog", gray_image) cv2.waitKey(0)
inverted_image = 255 - gray_image cv2.imshow("Inverted", inverted_image) cv2.waitKey()
blurred = cv2.GaussianBlur(inverted_image, (21, 21), 0)
inverted_blurred = 255 - blurred pencil_sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0) cv2.imshow("Sketch", pencil_sketch) cv2.waitKey(0)