Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get dct of an image in python using opencv

I've been trying to figure out a way of getting a DCT of image. After getting the image and doing a bunch of filtering, I want to calculate DCT. Following is the code sniplet:

imgcv1 = cv2.split(imgcv)[0] 
cv2.boxFilter(imgcv1, 0, (7,7), imgcv1, (-1,-1), False, cv2.BORDER_DEFAULT)
#resize image to 32x32
cv2.resize( imgcv1, (32, 32 ) ,imgcv1)

I've been trying to play around with the description given here but no success. When I tried something like:

dst = cv2.dct(imgcv1)

I get an error like:

cv2.error: /build/buildd/opencv-2.3.1/modules/core/src/dxt.cpp:2247: error: (-215) type == CV_32FC1 || type == CV_64FC1 in function dct

How can I get the dct? I would be grateful for your help.