Hi! I am looking at some code, that I found somewhere in the internet, to compute DCT for each 8x8 block in an gray (2D) image (512x512).
This is the code: def dct2(a): return scipy.fft.dct(scipy.fft.dct(a,axis=0,norm='ortho'),axis=1,norm='ortho') imsize=im.shape dct=np.zeros(imsize) # Do 8x8 DCT on image (in-place) for i in r_[:imsize[0]:8]: # Seems the same as "for i in np.arange(0,imsize[0],8)"! for j in r_[:imsize[1]:8]: dct[i:(i+8),j:(j+8)]=dct2(im[i:(i+8),j:(j+8)]) I tried to do the same thing with: imsize=im.shape im8=im.reshape(imsize[0]*imsize[1]//8//8,8,8) dct_test=np.asarray([dct2(im8x) for im8x in im8]) dct_test=dct_test.reshape(imsize) so that dct_test should be equal to (previous) dct. But they are completely different. What am I doing wrong? Thanks a lot. -- https://mail.python.org/mailman/listinfo/python-list