forked from Kushal-Pareek/CodeRed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_to_pencilsketch
More file actions
41 lines (23 loc) · 808 Bytes
/
image_to_pencilsketch
File metadata and controls
41 lines (23 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# CONVERT IMAGE INTO PENCIL SKETCH
# import required libraries
import cv2
# reading image
image = cv2.imread("panda.jpg")
# converting BGR image to grayscale
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# image inversion
inverted_image = 255 - gray_image
# Blur image
blurred = cv2.GaussianBlur(inverted_image, (21, 21), 0)
# Invert the Blurred image
inverted_blurred = 255 - blurred
# Divide grey_image and Inverted_blurred
pencil_sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
cv2.imshow("Original Image", image)
cv2.imshow("grey Image", gray_image)
cv2.imshow("inverted_image", inverted_image)
cv2.imshow("bluured", blurred)
cv2.imshow("inverted_bluured", inverted_blurred)
cv2.imshow("Pencil Sketch of Dog", pencil_sketch)
cv2.waitKey(0)
cv2.destroyAllWindows()