A few notes taken while reading the github.com/mandykoh/simian
code.
An index is a tree of nodes. Each node contains one or more entries. An entry is (roughly) a thumbnail of a given size, and the corresponding fingerprint. Within a node, entries are accessible by fingerprint.
Fingerprints provide a concept of "distance" between entries, and I guess (haven't read that yet) that the concept is used to make sure that all entries within a node are "closer" to each other than to any of the entries of any other node.
-
created from a JSON file located at some path, e.g.
some/path/example.json
(whatever the extension is, but the file must be valid JSON) -
inside that path, there is also a thumbnail (
.thumb
) named accordingly: e.gsome/path/example.thumb
-
no fingerprint, no attributes are set when creating the entry from a file
-
can also be created from an image, at any arbitrary size
-
in that case, the key is a random 64 character string (hex representation of random 32 bytes)
-
the thumbnail is generated at the given size (double of the
maxFingerprintSize
of the entry -- whatever that is) -
has a fingerprint (why is it called
MaxFingerprint
?)
- is an image.Image
- has a size (the smallest of its dimensions)
- has a size (twice as small as the corresponding thumbnail)
- is a function (specific/arbitrary) of a thumbnail of the given size (twice as small as the corresponding thumbnail for a given entry)
- the function clears the six (magic number) less significant bits of the grayscale component (Y in YCbCr) of each pixel of the image (I think that means ignoring the most detailed information about each pixel of the image, i.e. "blurring" the image).
As of this writing, it clears the four least significant bits. What it’s actually doing is turning each YCbCr pixel into one 4-bit sample (just the most important 4 bits of Y), so that we can pack two samples into an 8-bit value for efficiency (ie an 8 bit fingerprint sample actually represents two pixels from the original resized image). The implication is that two pixels which differ in brightness by up to 16 values can still be considered “the same.”
This is not the “blurring”…that happens when the original image is resized to the fingerprint size. This way of sampling the Y value gives us a bit of “bucketing” so that more things fall under the same fingerprint, so the levels of the tree that are closer to the index don’t need lots and lots of children. This stuff is likely to change a lot with DCT fingerprints.