diff options
Diffstat (limited to 'check/app/utils/im_utils.py')
| -rw-r--r-- | check/app/utils/im_utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/check/app/utils/im_utils.py b/check/app/utils/im_utils.py index 3002632..eae7bc1 100644 --- a/check/app/utils/im_utils.py +++ b/check/app/utils/im_utils.py @@ -208,6 +208,16 @@ def compute_phash(im): """ return imagehash.phash(ensure_pil(im)) +def compute_phash_int(im): + """Compute perceptual hash using ImageHash library and convert to binary + :param im: Numpy.ndarray + :returns: ImageHash as binary + """ + phash = imagehash.phash(ensure_pil(im)) + phash.hash[-1] = False + phash_as_bigint = struct.unpack('Q', numpy.packbits(phash.hash))[0] + return phash_as_bigint + def compute_dhash(im): """Compute difference hash using ImageHash library :param im: Numpy.ndarray |
