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.
I am confused that in the algorithm DCT is applied once whereas in the implementation of the Imagehash library they have applied DCT two times. More precisely look at the line given below:
dct = scipy.fftpack.dct(scipy.fftpack.dct(pixels, axis=0), axis=1)
I am not getting how DCT is applied in the above code.