Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. plot.imshow(np.reshape(images[index], (16,16), order='F'), cmap=cm.Greys_r)
  2.  
  3. def TileImage(imgs, picturesPerRow=16):
  4. # Convert to a true list of 16x16 images
  5. tmp = np.reshape(imgs, (-1, 16, 16), order='F')
  6. img = ""
  7. for i in range(0, tmp.shape[0], picturesPerRow):
  8. # On the last iteration, we may not have exactly picturesPerRow
  9. # images left so we need to pad
  10. if tmp.shape[0] - i >= picturesPerRow:
  11. mid = np.concatenate(tmp[i:i+picturesPerRow], axis=1)
  12. else:
  13. padding = np.zeros((picturesPerRow - (tmp.shape[0] -i), 16, 16))
  14. mid = np.concatenate(np.concatenate((tmp[i:tmp.shape[0]], padding), axis=0), axis=1)
  15.  
  16. if img == "":
  17. img = mid
  18. else:
  19. img = np.concatenate((img, mid), axis=0)
  20.  
  21. return img
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement