Guest User

Untitled

a guest
May 10th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/bin/env python
  2. import numpy as np
  3. import scipy.misc
  4. from scipy.fftpack import dct, idct
  5. import sys
  6.  
  7. H = 128
  8. W = 128
  9.  
  10. lenna = scipy.misc.imresize(scipy.misc.lena(), (H, W)).astype(float)
  11. lenna_F = dct(dct(lenna, axis=0), axis=1) ## 2D DCT of lenna
  12.  
  13. canvas = np.zeros((H,W))
  14. for h in range(H):
  15. for w in range(W):
  16. a = np.zeros((H,W))
  17. a[h,w] = 1
  18. base = idct(idct(a, axis=0), axis=1) ## create dct bases
  19. canvas += lenna_F[h,w] * base ## accumulate
  20. scipy.misc.imsave("base-%03d-%03d.png" % (h, w), base)
  21. scipy.misc.imsave("lenna-%03d-%03d.png" % (h, w), canvas)
Advertisement
Add Comment
Please, Sign In to add comment