Low quality image comparing

asked 2014-09-16 11:11:35 -0500

updated 2020-11-08 09:23:18 -0500

Hi! I have web service for searching my images. I use opencv (2.4.9) orb feature to get keypoints and Phash lib to convert them into unsigned bigint numbers, that can be compared with the hamming distance. As I remember, it worked fine, but since some magic happens, the quality of comparison became very low. For example, even making a little watermark on image makes 70% difference of keypoints (even using comparion with hamming distance). What could happens? Here is code (python2) I use to get keypoint hashes:

img1 = Image.read( '/var/www/image.jpg')
kp1, desc1 = cv2.ORB( 200 ).detectAndCompute( img1.img, None )
e1 = Extractor( img1, kp1, desc1 )
imgs1 = e1.binImages()

matcher = Matcher( [PHash] )
hashes = matcher.hashes( imgs1, True )[PHash]
phs = []

for h in hashes:
    phs.append(str( h ))

print json.dumps(phs)

matcher.hashes() implimentation:

def hashes( self, imgs, checkDuplicates = True ):
        result = {}
        for h in self._hashes:
            if h not in result:
                result[h] = []

            for i in imgs:
                hash = h( i )
                found = False
                if checkDuplicates:
                    for sh in result[h]:
                        if sh == hash:
                            found = True

                if not found:
                    result[h].append( hash )

        return result

System is typical vps: Linux version 3.2.0-4-amd64 ([email protected]) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.54-2 I don't know whether any other info is required

Image examples for compare attached: 11.jpg and 22.jpg . I got about 170 hashes for them, but only 9 are alike (with hamming distance <=7).


edit retag flag offensive close merge delete