The phash algorithm is as follows:
- Convert the image to greyscale and scale to 32x32.
- Compute the discrete cosine transform of this scaled image. Discard all components of the DCT except the upper-left 8x8 portion.
- Find the median value of the reduced DCT.
- For each bit in the output hash,set it to 1 if the corresponding component of the reduced DCT is greater than the median, or 0 otherwise.
Facebook PDQ:
- PDQ begins with a normalization step, which processes the luminance data from the input image.
- A two-pass Jarosz filter to downsample the image to 64 × 64. Within the downsampled image, compute a sum of absolute values of horizontal and vertical gradients along with a two-dimensional discrete cosine transform, resulting in a 16 × 16 DCT.
- For each of the 16x16 bits of the output hash, emit a 1 if the corresponding element of transform is greater than the median, otherwise emit a 0; the resulting 256 bits form the output digest.
The facebook PDQ algorithms is an extended version of the phash algorithms. The output of the phash algorithm is 64 bit where as the output of the Facebook PDQ algorithm is 256 bits. The number of bits used by PDQ is very high as compared to the phash, Thus my question is, Is it a good idea to say that PDQ is better than phash? Note that better means robust which means it can catch the manipulations on the images.