【问题标题】:Image Comparison with a updating comparison image (PIL)与更新比较图像 (PIL) 的图像比较
【发布时间】:2020-05-28 13:27:41
【问题描述】:

我需要比较文件夹中的第一张图片,删除重复的图片,直到找到不匹配的图片。然后它将新图像与图片的其余部分进行比较,重复第一个过程。我不知道我是否忘记了一些明显的事情,但是如何将新图像设置为比较。下面是我的第一次尝试,im1 的 first_image 将在循环后更新。任何意见,将不胜感激。

def add():
    for image in files:
        im1 = Image.open(path+ "/"+first_image).histogram() #the image to be compared too
        im = Image.open(path+ "/" +image).histogram() #the image to be compared
    if im == im1:
        os.rename(path + "/" + file, path + "/delete")
    else: 
        os.rename(path + "/" + file, path + "/save") ```

【问题讨论】:

    标签: python-3.x image-comparison


    【解决方案1】:

    答案很简单,想多了。刚刚在 for 循环之前定义了图像,然后让 for 循环根据需要更新它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 2011-01-09
      • 1970-01-01
      • 2013-02-22
      相关资源
      最近更新 更多