torch-dct icon indicating copy to clipboard operation
torch-dct copied to clipboard

These results are different from those with cv2.dft

Open lilu1996 opened this issue 4 years ago • 1 comments

input image "im_gray" of uint8 and size of [256,256], then i made following operations with opencv and torch-dct, respectively: a = cv2.dct(im_gray.astype("float")) b = torch_dct.dct_2d(torch.from_numpy(im_gray.astype("float"))). But a and b are greatly different.

lilu1996 avatar Dec 04 '19 08:12 lilu1996

Are you sure you used the same norm method as in cv2? Try this:

a = cv2.dct(im_gray.astype("float")) b = torch_dct.dct_2d(torch.from_numpy(im_gray.astype("float")), norm='ortho')

I suppose both cv2 and MatLab use the orthogonal factor as default.

DYin65535 avatar Jan 06 '20 15:01 DYin65535