Calculate the Similarity Between Image Hashes in JavaScript

Cloudmersive
Apr 26, 2021

--

Have a couple perceptual image hashes you need to calculate the similarity between? In this tutorial, we will save you a whole lot of time by providing instructions on how to use an API in JavaScript to calculate similarity by determining the Hamming Distance between the two hashes.

Let’s get this process started by installing the jQuery library:

bower install jquery

With the installation out of the way, we can call the function:

var settings = {
"url": "https://api.cloudmersive.com/image/recognize/similarity/hash/distance",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"ImageHash1": "<string>",
"ImageHash2": "<string>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});

Your similarity score will be generated instantaneously, allowing you to maintain productivity and efficiently accomplish your task.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet