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 86
| from tkinter import *
import ctypes
import tkinter.filedialog
from PIL import Image
import sys, os
import math
from functools import reduce
import operator
def Ouvrir():
global filename
filename = tkinter.filedialog.askopenfilename(title="Ouvrir une image",filetypes=[('all files','.*')])
print(filename)
photo = PhotoImage(file=filename)
gifdict[filename] = photo
print(gifdict)
Canevas.create_image(0,0,anchor=NW,image=photo)
Canevas.config(height=photo.height(),width=photo.width())
fenetre.title("Image "+str(photo.width())+" x "+str(photo.height()))
def Fermer():
Canevas.delete(ALL)
fenetre.title("Comparate PlateNumber")
filename = 0
def compare():
image1 = Image.open("img1.png")
image2 = Image.open(filename)
h1 = image1.histogram()
h2 = image2.histogram()
rms = math.sqrt(reduce(operator.add,
map(lambda a,b: (a-b)**2, h1, h2))/len(h1))
print (rms)
if rms == 0:
print("Identique")
Mbox('Comparaison', 'Identique', 1)
else:
print("Différent")
Mbox('Comparaison', 'Différent', 1)
def Mbox(title, text, style):
ctypes.windll.user32.MessageBoxW(0, text, title, style)
fenetre = Tk()
fenetre.title("Image")
menubar = Menu(fenetre)
menufichier = Menu(menubar,tearoff=0)
menufichier.add_command(label="Ouvrir une image",command=Ouvrir)
menufichier.add_command(label="Fermer l'image",command=Fermer)
menufichier.add_command(label="Quitter",command=fenetre.destroy)
menubar.add_cascade(label="Fichier", menu=menufichier)
fenetre.config(menu=menubar)
label = Label(fenetre, text="Plaque Auto")
label.pack()
bouton = Checkbutton(fenetre, text="Luigi")
bouton.pack()
bouton = Checkbutton(fenetre, text="Corentin")
Button(fenetre, text = 'Comparer', command=compare).pack(side=LEFT, padx=5, pady=5)
bouton.pack()
photo = PhotoImage(file="img1.png")
zone_dessin = canvas = Canvas(fenetre,width=600, height=150, borderwidth=8)
zone_dessin.create_image(300,65,image=photo)
canvas.pack()
Canevas = Canvas(fenetre)
Canevas.pack(padx=5,pady=5)
gifdict={}
fenetre.mainloop() |
Partager