图像匹配 欧氏距离 直方图匹配 python

基于两幅图像间欧氏距离和直方图匹配的图像匹配python

# 创建GUI窗口打开图像 并显示在窗口中
import tkinter as tk           # 导入GUI界面函数库
from tkinter import *
import tkinter.filedialog
from PIL import Image, ImageTk # 导入图像处理函数库
from os import listdir
import numpy as np
import cv2


path = r'C:/Users/song/Desktop/set/'#图像文件夹

# 创建窗口 设定大小并命名
window = tk.Tk()
window.title('图像匹配')
window.geometry('800x600')
var = tk.StringVar()    # 这时文字变量储存器
lb = Label(window,text='')


def input_file_name():
    global img_current
    global file_name
    file_name = str(inp1.get())
    imagesList = listdir(path)
    for image in imagesList:
        if (image==file_name):
            img = Image.open(path + image)
            img_current = ImageTk.PhotoImage(img)
            label_Img = tk.Label(window, image=img_current)
            label_Img.place(relx=0.25,rely=0,relheight=0.3,relwidth=0.3)     


def Euc():
    Euc_dist_list=[]
    image_list=[]
    imagesList = listdir(path)
    cnt=0
    global Euc_image
    dist=float('inf')
    for image in imagesList:
        if image!=file_name:
            cnt = cnt+1
            current_image=np.array(Image.open(path + file_name))
            other_image=np.array(Image.open(path + image))
            image_dist = np.linalg.norm(current_image-other_image)
            Euc_dist_list.append(image_dist)
            image_list.append(image)
            #sim = 1/(1+dist)
            if image_dist

程序 

你可能感兴趣的:(python)