Amish
Amish

Reputation: 197

Different outputs of DCT from OpenCV and Scipy.fftpack.dctn?

I am calculating DCT of grayscale image of size 32x32

def _dct(image):
    result = cv2.dct(np.float32(image)/255.0)
    return (result * 255.0)
dctn(image)

Output of both functions first using cv2.dct() then using scipy.fftpack.dctn() Output

Upvotes: 2

Views: 461

Answers (1)

Amish
Amish

Reputation: 197

The reason is of this behaviour is listed here https://docs.scipy.org/doc/scipy/reference/generated/scipy.fftpack.dct.html

Answer : dctn(image, norm = "ortho")

Reason : In case of norm = "ortho" resulting DCT is multiplied with scaling factor f which results in same output as given by _dct using OpenCV.

f = sqrt(1/4N) when k = 0 
    sqrt(1/2N) otherwise 

Upvotes: 5

Related Questions