示例#1
0
def startSearch0(var1, var2, var3, tree, x, root1):  #所有子文件夹
    count1 = 0
    path = var2.get()
    im1 = Image.open(var1.get())

    #Const_Image_Format = [".jpg",".jpeg",".bmp",".png"]
    for (root, dirs, files) in os.walk(path):
        for filename in files:
            if os.path.splitext(filename)[1] in Const_Image_Format:  #筛选格式

                sizePingheng = 51  #现在只改这个就好了
                pingheng = 100 / (sizePingheng - 1)**2
                im2 = Image.open(os.path.join(root, filename))
                j = pingheng * ((sizePingheng - 1)**2 - _dhash.classfiy_dHash(
                    im1, im2, size=(sizePingheng, sizePingheng - 1)))

                count1 += 1
                x.set('已处理' + str(count1) + '张')
                root1.update()  #显示处理过程

                if j >= int(var3.get()):  #条件筛选

                    treePrint(
                        tree,  #调用打印函数
                        round(j, 2),
                        os.path.join(root),
                        os.path.splitext(filename)[0],
                        os.path.splitext(filename)[1],
                        os.path.getsize(os.path.join(root, filename)),
                        im2,
                        os.path.getctime(os.path.join(root, filename)),
                        "")
示例#2
0
def startSearch01(var1, var2, var3, tree, x, root1):
    count1 = 0
    path = var2.get()
    im1 = Image.open(var1.get())
    global len
    len = str(len(os.listdir(path)))  #显示总文件数量
    #Const_Image_Format = [".jpg",".jpeg",".bmp",".png"]
    for filename in os.listdir(path):
        if os.path.splitext(filename)[1] in Const_Image_Format:  #筛选格式

            im2 = Image.open(os.path.join(path, filename))
            j = 100 - 2.38 * _dhash.classfiy_dHash(im1, im2, size=(7, 6))

            count1 += 1
            x.set(len + '个文件中,处理了' + str(count1) + '张')
            root1.update()  #显示处理过程

            if j >= int(var3.get()):  #条件筛选

                treePrint(
                    tree,  #调用打印函数
                    round(j, 2),
                    os.path.join(path),
                    os.path.splitext(filename)[0],
                    os.path.splitext(filename)[1],
                    os.path.getsize(os.path.join(path, filename)),
                    im2,
                    os.path.getctime(os.path.join(path, filename)),
                    "")
示例#3
0
def startSearch():
    im1=Image.open( var1.get())
    #遍历文件夹并传到列表
    Const_Image_Format = [".jpg",".jpeg",".bmp",".png"]
    path= var2.get()
    list1=[]
    for (root, dirs, files) in os.walk(path):  
        for filename in files:
            if os.path.splitext(filename)[1] in Const_Image_Format :
                #print(os.path.join(root,filename))
                list1.append(os.path.join(root,filename))
    #遍历比较
    list2=[]
    for i in list1:
        im2=Image.open(i)
        j=_dhash.classfiy_dHash(im1,im2,size=(9,8))
        if j<=int(var3.get()):
            print(j)
            print(i)
            list2.append(str(100-3*j)+'%')
            list2.append(i)
    #在listbox显示
    lb.delete(0, END) 
    for item in list2:
        lb.insert(END, item)    
    #====================================
    load = Image.open(var1.get()) 
    render=load.resize((300,200),Image.ANTIALIAS) 
    render_ed= ImageTk.PhotoImage(render)  
    canvas.delete('all')
    canvas.create_image(0,0,anchor=NW,image=render_ed)
示例#4
0
def comp_faces(faces1, faces2, size, part_size):
    min_code = 100
    for face1 in faces1:
        for face2 in faces2:
            code = _dhash.classfiy_dHash(face1, face2,
                                         size=(11,
                                               10))  #来自d哈希的对比~~~~~~~~~~~~~~
            if code < min_code:
                min_code = code
    return min_code
示例#5
0
def classify_passage(img1Path, img2Path):

    image1 = Image.open(img1Path)
    b1 = image1.split()[0]  # rgb通道分离
    g1 = image1.split()[1]  # rgb通道分离
    r1 = image1.split()[2]  # rgb通道分离

    image2 = Image.open(img2Path)
    b2 = image2.split()[0]  # rgb通道分离
    g2 = image2.split()[1]  # rgb通道分离
    r2 = image2.split()[2]  # rgb通道分离

    result = 0
    result1 = _dhash.classfiy_dHash(b1, b2, size=(11, 10))
    result2 = _dhash.classfiy_dHash(g1, g2, size=(11, 10))
    result3 = _dhash.classfiy_dHash(r1, r2, size=(11, 10))

    #print(max(result3,result2,result1))

    #采用最大值就是省去了其他未画的部分的对比差异
    return max(result3, result2, result1)