-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Phasher is an android based library which is based on Phash (perceptual hash) algorithm.
The fastest way to remove high frequencies and detail is to shrink the image. In this case, shrink it to 8x8 so that there are 64 total pixels. Don't bother keeping the aspect ratio, just crush it down to fit an 8x8 square. This way, the hash will match any variation of the image, regardless of scale or aspect ratio.
The tiny 8x8 picture is converted to a grayscale. This changes the hash from 64 pixels (64 red, 64 green, and 64 blue) to 64 total colors.
Compute the mean value of the 64 colors.
This is the fun part. Each bit is simply set based on whether the color value is above or below the mean.
Set the 64 bits into a 64-bit integer. The order does not matter, just as long as you are consistent.