commonsmachinery / blockhash-js Goto Github PK
View Code? Open in Web Editor NEWImage perceptual hash calculation in javascript
Home Page: http://blockhash.io/
License: MIT License
Image perceptual hash calculation in javascript
Home Page: http://blockhash.io/
License: MIT License
blockhash.js file is missing from both sources and from release
I needed to use blockhash-core in my Android app. So, I followed your C and JS implementations, and implemented it in Java. I was wondering if you'd be interested in mentioning the repo on your website or maybe move repository to your org?
Here is the link to java implementation: https://github.com/bbhopesh/blockhash-java
blockhash-java-lib
is the Java implementation without any Android dependencies. blockhash-android-lib
is wrapper for Android.
Same as in commonsmachinery/blockhash#23 in the C implementation and commonsmachinery/blockhash-python#9 in the Python implementation. Likely contributes to issue #7 since this causes all hashes to be incorrect.
Line 28 in ef9e1ed
If so , please shoot me an email at [email protected]
blockhash-js
should be able to detect the image type from the arrayBuffer directly, without having to resort to the content type of the xhr request. See:
http://stackoverflow.com/questions/8349693/how-to-check-if-a-byte-array-is-a-valid-image
http://stackoverflow.com/questions/25841460/how-to-recognise-the-arraybuffer-is-string-or-image
http://stackoverflow.com/questions/4550296/how-to-identify-contents-of-a-byte-is-a-jpeg
This would allow the library to support hashing from an arrayBuffer from an instance of the FileReader class without having to supply content type.
which algorithimn is used here? Because by
https://content-blockchain.org/research/testing-different-image-hash-functions/
We have two TYPES OF ALG. --->
BLOCKHASH - PERCEPTUAL HASH
ok, the name of this repo is blockhash-js, which one may think it is a blockhash based alg. But in the description it says "This is a perceptual image hash", which one may think it is a perceptual hash. (Of course, all both are for perception diff.)
But which of these two is the alg. used here? (Need some clarification on docs, because i got confused)
The "-js" suffix is not necessary to include in the package name, since it is implied that anything on npm is javascript. The package name and repository names doesn't have to be the same.
I get an "Error: Couldn't decode image" message when I attempt to use blockhash on an image file stored locally on my computer, for example "C:\Users\Bob\Desktop\blockhash\image.jpg". I have no issue with files stored online, for example "http://example.com/image.jpg". Is it possible to use the Javascript version of blockhash on local files? Is there a step I'm missing to do this? Thanks!
It seems like the command npm install blockhash-js doesnt work. Apparently iit is not yet registered with the npm registry. Is it really registered yet or in due process?
The public version on npmjs https://www.npmjs.com/package/blockhash is still version 0.2.0, whereas the version in the repo is already 0.3.0
I want to get two hashes for an image -- one for the original and one in which the image is mirrored across the Y axis (mirror image).
I tried creating another result
array with values in blocks reversed here but somehow am ending up with the same output from translate_blocks_to_bits
so im afraid I'm missing something obvious.
Any hints on how I could accomplish this?
dependence png-js doesnt exist. even after sudo npm install png-js and it existing on my node_modules or yarn add... Why?
It would be useful to be able to support GIF. This is some JS code for a GIF decoder that may be useful in this: https://github.com/deanm/omggif
ReferenceError: XMLHttpRequest is not defined
Getting this error when using this in nodejs
console.log(blockhash.blockhash(buffer, 7))
This image: https://commons.wikimedia.org/wiki/File:Arius.png
It's getting incorrectly hashed by blockhash-js, which gives a hash of 00ec008bbe80ffbf0000e9f9f8fb80fdffffffffffffffffffffffffffffffff instead of 0ff91ff10ff1000300018fd984d79ddf8e058fc30fc30fc3dfc3c3c303831783 as would be expected (from the C blockhash). The trailing fffff is a tell tale sign of an issue, which look very similar to the issue we had with jpeg where jpeg-js made assumptions about the image being RGB. Could something similar be amiss here?
I was wondering if anyone could shed light on the one_bits array since I do not have access to the original paper upon which this library is based.
I can see that the hammingDistance function essentially calculates the bit difference between the relevant char in the two hashes to be compared. this XOR operation n1^n2 will, in theory, be in the range 0 to 15, since parseInt("0",16)=0 and parseInt("f",16)=15.
So my question is that the one_bits array seems to essentially "decelerate" the hamming distance by increasing the distance by either 0,1,2,3, or 4 instead of the bit difference (0-15). Why does the algorithm do this?
var one_bits = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4];
Interestingly, the one_bits array is non-linear, so a bit difference of 3 will increase distance by 2 whereas a bit difference of 4 will increase distance by 1...??
Thanks!
median([1,2,3,4]) should return 2.5, but the current implementation mistakenly returns 3.5 due to a bug in index calculation:
var median = function(data) {
var mdarr = data.slice(0);
mdarr.sort(function(a, b) { return a-b; });
if (mdarr.length % 2 === 0) {
return (mdarr[mdarr.length/2] + mdarr[mdarr.length/2 + 1]) / 2.0;
}
return mdarr[Math.floor(mdarr.length/2)];
};
should be
var median = function(data) {
var mdarr = data.slice(0);
mdarr.sort(function(a, b) { return a-b; });
if (mdarr.length % 2 === 0) {
return (mdarr[mdarr.length/2 - 1] + mdarr[mdarr.length/2]) / 2.0;
}
return mdarr[Math.floor(mdarr.length/2)];
};
Im not familiar w/ image or file handling, so the language about the bits
param in the docs is unclear to me. Can someone elaborate on what is meant by "number of bits in a row"?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.