0
$\begingroup$

The phash algorithm is as follows:

  1. Convert the image to greyscale and scale to 32x32.

  2. Compute the discrete cosine transform of this scaled image. Discard all components of the DCT except the upper-left 8x8 portion.

  3. Find the median value of the reduced DCT.

  4. 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.

$\endgroup$

1 Answer 1

2
$\begingroup$

The algorithm uses a 2D DFT. Your Python code implements that 2D DCT through a set of row-wise, followed by a set of column-wise, 1D DCTs.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.