How to Calculate Perceptual Image Hash Similarity, Hamming Distance using Python

Once you generate a perceptual hash for an image, you can use that hash to compute the Hamming Distance between it and the hash of another image. With the ready-to-run Python code provided below, you can easily compare two perceptual image hash strings in a single request and return an image similarity score (which represents the Hamming Distance). This API will instantly add a useful digital forensics feature to your application with zero hassle.

To install the Python SDK, run this command:

To complete your API call, add the imports and call the function:

Make sure to pass a valid Cloudmersive API key with your request, and you’re all set. To get an API key for free, visit our website and register a free account (free accounts provide a limit of 800 API calls per month & no additional commitments).

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.