In scipy why doesn't idct(dct(a)) equal to a?

天涯浪子 提交于 2019-12-04 06:25:24

You need to set scaling to ortho for both dct2 and idct2:

def dct2 (block):
  return dct(dct(block.T, norm = 'ortho').T, norm = 'ortho')

also, you cannot expect the values to be exactly the same, but almost the same within some margin of error:

np.allclose (a, idct2(dct2(a)))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!