Using this script, users can convert images to corresponding pencil sketches. The script uses OpenCV.
Using OpenCV and Python, an RGB color image can be converted into a pencil sketch in four simple steps:
- Convert the RGB color image to grayscale.
- Invert the grayscale image to get a negative.
- Apply a Gaussian blur to the negative from step 2.
- Blend the grayscale image from step 1 with the blurred negative from step 3 using a color dodge.
- Step 1: Get the image and convert it into grayscale by using COLOR_BGR2GRAY from cv2.
-
Step 2: Invert the image i.e, obtain the negative of the grayscale image using bitwise_not from cv2.
-
Step 3: Blur the image by applying Gaussian filter to the inverted image.
-
Step 4: Merge the gray scale image and the Gaussian filter applied image.
The sketch is ready!