rhsimplex / image-match

🎇 Quickly search over billions of images
2.94k stars 405 forks source link

Completely fails to detect cropped versions of images added to index #109

Closed bhavikshah1995 closed 5 years ago

bhavikshah1995 commented 5 years ago

I tried searching for cropped versions of images that were added to the index, but the results were completely off, such that the original image from which I had cropped the search image didn't even make it (even after extending distance_cutoff to 0.80). Is there any way we can work around this issue or is this a flaw in the algorithm itself that cannot be easily fixed?

duhaime commented 5 years ago

@bhavikshah1995 could you post some example images before and after the crop?

Could you also post the minimal code you're using to process your images?

I have identified hundreds of thousands of matching images that involve crops with image-match, but my data consisted mostly of line drawings.

bhavikshah1995 commented 5 years ago

@duhaime Here are some examples in the order of uncropped image in the index and cropped image being searched:

i0a2fd597128c11db9780000d60993453_uncropped gyrotonic_cropped

i0a6da9427b6011dfbd20d521083c470e_uncropped smile_cropped

i6ea07216027711e4a60ae2600c90d6b4_uncropped greens_cropped

i7dd1f2c9b7e111df83eb9cce9d08ff46_uncropped aad_cropped

Here's the code I'm using to process the images:

from elasticsearch import Elasticsearch
from image_match.elasticsearch_driver import SignatureES
es = Elasticsearch()
ses = SignatureES(es, distance_cutoff = 0.50)

import os
files_path = 'C:\\Users\\UC244373\\Python_Images\\Sample_images\\'
for filename in os.listdir(files_path):
    ses.add_image('C:\\Users\\UC244373\\Python_Images\\Sample_images\\'+filename)

path = 'C:\\Users\\UC244373\\Pictures\\Screenshots\\Image Examples\\greens_cropped.png'
ses.search_image(path, all_orientations=True)

Note that the images I have added to the index are of .mm file type, but I have tested the above for .png file types as well, with the same lack of result.

rhsimplex commented 5 years ago

I'm surprised the AAD example didn't work, but the others are simply to extreme for this algorithm. You can try lowering the match thereshold, but I'm certain the other three examples will never work.

bhavikshah1995 commented 5 years ago

@rhsimplex You mention in issue #40 that the algorithm is theoretically capable of heavy cropping. Is there any way you could shed some light on how one can go about implementing this?