forked from deucalionn/Image-to-pencil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
405ada4
commit 50a9a3f
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import cv2 | ||
import sys | ||
import tkinter as tk | ||
from tkinter.filedialog import askopenfilename | ||
import inquirer | ||
from inquirer.themes import GreenPassion | ||
import time | ||
|
||
def main(): | ||
image_choice = askopenfilename() | ||
image = cv2.imread(image_choice) | ||
grayimage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | ||
grayimageInv = 255 - grayimage | ||
grayimageInv = cv2.GaussianBlur(grayimageInv, (21, 21), 0) | ||
output = cv2.divide(grayimage, 255-grayimageInv, scale=256.0) | ||
cv2.namedWindow("image", cv2.WINDOW_AUTOSIZE) | ||
cv2.namedWindow("pencilsketch", cv2.WINDOW_AUTOSIZE) | ||
cv2.imshow("image", image) | ||
cv2.imshow("pencilsketch", output) | ||
cv2.waitKey(0) | ||
cv2.destroyAllWindows() | ||
|
||
def intro(): | ||
print(""" | ||
___ _____ ___ _ _ | ||
|_ _|_ __ __ _ __ _ ___ |_ _|__ | _ \___ _ _ __(_) | | ||
| || ' \/ _` / _` / -_) | |/ _ \ | _/ -_) ' \/ _| | | | ||
|___|_|_|_\__,_\__, \___| |_|\___/ |_| \___|_||_\__|_|_| | ||
|___/ | ||
Transformez vos images avec un style pencil / dessin | ||
By Deucalion | ||
github : https://github.com/deucalionn | ||
""") | ||
time.sleep(1) | ||
|
||
introd = [ | ||
inquirer.List('introd', | ||
message="Que voulez vous faire ? ", | ||
choices=['Transformer une image', 'Quitter'], | ||
default='Transformer une image'), | ||
] | ||
answers = inquirer.prompt(introd, theme=GreenPassion()) | ||
if answers.get('introd') == "Transformer une image": | ||
main() | ||
else: | ||
quit() | ||
|
||
|
||
intro() |