Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 18a9b86

Browse files
Merge pull request #725 from Emanalytics7/main
added sketchifyme
2 parents e7365f2 + 94dfe7a commit 18a9b86

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

projects/SketchifyMe/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SketchifyMe
2+
3+
Seamlessly convert your images into pencil-sketch renditions, facilitating the effortless creation of your sketches.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import cv2
2+
import numpy as np
3+
4+
5+
def image_to_sketch(image_path):
6+
img = cv2.imread(image_path)
7+
# converting to gray scale
8+
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
9+
10+
# applying gaussian blur
11+
blurred_img = cv2.GaussianBlur(gray_img, (21, 21), 0)
12+
inverted_blurred_img = cv2.bitwise_not(blurred_img)
13+
sketch_img = cv2.divide(gray_img, inverted_blurred_img, scale=256.0)
14+
cv2.imshow('Pencil Sketch', sketch_img)
15+
cv2.waitKey(0)
16+
cv2.destroyAllWindows()
17+
18+
# save the results
19+
output_file_name = 'sketch_of' + '' + image_path
20+
output = cv2.imwrite(output_file_name, sketch_img)
21+
print(f'Saved the Sketch!')
22+
return output
23+
24+
25+
26+
if __name__ == '__main__':
27+
image = '# your image'
28+
image_to_sketch(image)
29+
30+
31+
32+
33+

0 commit comments

Comments
 (0)