image-signature
Function that generates a hash for a canvas image that can be used to identify similar images
Written in Scala, transpiled to JavaScript with ScalaJS
(JVM compilation target coming soon!)
const signature = // getting image data from canvaslet canvas = document;let context = canvas;let img = document;context;let imageData = context; // calculating the signaturelet sig = signature// finding the "distance" (similarity) between two imageslet distance = signature
The signature is an array of 81 arrays, one for each grid point in a 10x10 grid. Each array contains comparisons of grid pieces of image with each other (much darker, darker, same, lighter, much lighter). The algorithm used to generate the signature is based on the method described in Goldberg, et al.
The calculated "distance" is a measure of the similarity between the images. It is computed as the normalized L2 norm of the signature, as described in the Goldberg paper.
This package is the core algorithm used for comparing images and video frames in the Chrome extension Saucer.