In scipy why doesn't idct(dct(a)) equal to a?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle4
--
Chapters
00:00 In Scipy Why Doesn'T Idct(Dct(A)) Equal To A?
01:00 Accepted Answer Score 13
01:17 Thank you
--
Full question
https://stackoverflow.com/questions/3489...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #scipy #dct
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle4
--
Chapters
00:00 In Scipy Why Doesn'T Idct(Dct(A)) Equal To A?
01:00 Accepted Answer Score 13
01:17 Thank you
--
Full question
https://stackoverflow.com/questions/3489...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #scipy #dct
#avk47
ACCEPTED ANSWER
Score 13
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)))