-
Notifications
You must be signed in to change notification settings - Fork 0
/
App_mirror.py
85 lines (74 loc) · 2.26 KB
/
App_mirror.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#Date: 20th July, 2020
#Dang Thai Hai Vu _ Author
#Email: [email protected]
#Odontology project with DDS. Nguyen Dac Bao Chinh (DDS at HT Smile)
#Type: include mirror
from tkinter import *
from tkinter import messagebox
import glob
import os
import PIL
from PIL import Image
# Notification GUI
def notibox():
window = Tk()
window.eval('tk::PlaceWindow %s center' % window.winfo_toplevel())
window.withdraw()
messagebox.showinfo('HT_Smile','Task has been done !')
window.deiconify()
window.destroy()
window.quit()
# Lower Jaw: Flip and Rotate 180 deg
def Lower_Jaw(foto):
im = Image.open(foto)
img = im.transpose(PIL.Image.FLIP_LEFT_RIGHT).rotate(180)
dst = os.path.splitext(foto)[0] + " flipped" + ".jpg"
img.save(foto)
os.rename(foto,dst)
# Upper Jaw: Flip
def Upper_Jaw(foto):
im = Image.open(foto).convert('RGB')
img = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
dst = os.path.splitext(foto)[0] + " flipped" + ".jpg"
img.save(foto)
os.rename(foto,dst)
# Left Jaw: Flip
def Left_Jaw(foto):
im = Image.open(foto).convert('RGB')
img = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
dst = os.path.splitext(foto)[0] + " flipped" + ".jpg"
img.save(foto)
os.rename(foto,dst)
# Right Jaw: Flip
def Right_Jaw(foto):
im = Image.open(foto).convert('RGB')
img = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
dst = os.path.splitext(foto)[0] + " flipped" + ".jpg"
img.save(foto)
os.rename(foto,dst)
if __name__ == "__main__":
#Path of the source data:
dirName = 'C:\\Users\\vudan\\OneDrive\\Desktop\\Automation Project\\Odontology\\Flip-image\\images'
#Create list that keeps the foto
allFiles = list()
listofFile = os.listdir(dirName)
listofFile.sort()
for files in listofFile:
fullPath = os.path.join(dirName,files)
allFiles.append(fullPath)
#Start to rotate foto, this loop will run through each case resprectively
# and repeat until it reach the last foto
i=0
print(allFiles)
while i < (len(allFiles)):
#No3_Lower_Jaw
i += 4
Lower_Jaw(allFiles[i])
#No4_Upper_Jaw
i += 1
Upper_Jaw(allFiles[i])
if i == len(allFiles):
break
i += 1
#Notification box
notibox()