gpt4 book ai didi

tensorflow - 在本地计算机上反向图像搜索(用于图像重复)

转载 作者:行者123 更新时间:2023-12-03 13:37:36 25 4
gpt4 key购买 nike

我有一堆从 pdf 中提取的质量较差的照片。我认识的某个人在她的电脑 (Mac) 上某处有高质量的照片,但我的理解是很难找到它们。
我想要

  • 循环查看每张劣质照片
  • 使用每张质量较差的照片作为查询图像并使用此人的计算机作为数据库执行反向图像搜索以搜索更高质量的图像
  • 并在一个目标文件夹中创建每个高质量图像的副本。

  • 示例伪代码
    for each image in poorQualityImages:
    search ./macComputer for a higherQualityImage of image
    copy higherQualityImage to ./higherQualityImages
    我需要执行一次此操作。
    我在找 工具、github 存储库或库 它可以执行此功能,而不是对基于内容的图像检索的深刻理解。

    a post on reddit有人试图做类似的事情
    imgdupes是一个看起来几乎可以实现这一点的程序,但我不想删除重复项,我想将最高质量的副本复制到目标文件夹

    更新
    给我以前的图像处理教授发了电子邮件,他给我发了这个

    Off the top of my head, nothing out of the box.

    No guaranteed solution here, but you can narrow the search space.You’d need a little program that outputs the MSE or SSIM similarityindex between two images, and then write another program or shellscript that scans the hard drive and computes the MSE between eachimage on the hard drive and each query image, then check the imageswith the top X percent similarity score.

    Something like that. Still not maybe guaranteed to find everythingyou want. And if the low quality images are of different pixeldimensions than the high quality images, you’d have to do some imagescaling to get the similarity index. If the poor quality images havedifferent aspect ratios, that’s even worse.

    So I think it’s not hard but not trivial either. The degree ofdifficulty is partly dependent on the nature of the corruption in thelow quality images.



    更新
    Github project I wrote which achieves what I want

    最佳答案

    What you are looking for is called image hashing . In this answer you will find a basic explanation of the concept, as well as a go-to github repo for plug-and-play application.



    Hashing的基本概念

    From the repo page :“我们开发了一种基于 Marr 小波的新图像哈希,它根据边缘信息计算感知哈希,特别强调角落。已经表明,人类视觉系统特别利用某些视网膜细胞来区分角状刺激。相信这种角点信息可用于区分数字图像,从而激发了这种方法。基本上,从小波获得的边缘信息被压缩为 72 字节的固定长度散列。二进制量化允许相对较快的汉明距离散列之间的计算。下面的散点图显示了我们标准图像语料库的结果。第一个图显示了每个图像与其攻击对应物之间的距离(例如内部距离)。第二个图显示了完全不同图像之间的距离。虽然散列不是为处理旋转图像而设计的,但请注意轻微的旋转通常仍然落在阈值 r 内ange,因此通常可以匹配为相同。然而,这个散列的真正优势是与我们的 mvp 树索引结构一起使用。由于它比 dct 哈希更具描述性(长度为 72 个字节,而 dct 哈希为 8 个字节),因此为图像查询检索到的错误匹配要少得多。


    另一个 blogpost用于深入阅读,并附有应用示例。

    可用代码和用法

    可以找到 github 存储库 here .显然还有更多的发现。
    导入包后,您可以使用它来生成和比较哈希:
    >>> from PIL import Image
    >>> import imagehash
    >>> hash = imagehash.average_hash(Image.open('test.png'))
    >>> print(hash)
    d879f8f89b1bbf
    >>> otherhash = imagehash.average_hash(Image.open('other.bmp'))
    >>> print(otherhash)
    ffff3720200ffff
    >>> print(hash == otherhash)
    False
    >>> print(hash - otherhash)
    36

    演示 script find_similar_images同样在提到的 github 上,说明了如何在目录中找到类似的图像。

    关于tensorflow - 在本地计算机上反向图像搜索(用于图像重复),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61553923/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com