Guest User

Untitled

a guest
Mar 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import skimage
  2. from skimage import data
  3. from skimage import color
  4. from skimage.util import view_as_blocks
  5. import matplotlib.pyplot as plt
  6. import numpy as np
  7. from skimage.feature import corner_harris, corner_peaks
  8.  
  9. import os
  10. filename = os.path.join(skimage.data_dir, 'moon.png')
  11. from skimage import io
  12. moon = io.imread(filename)
  13.  
  14. # get astronaut from skimage.data in grayscale
  15. l = color.rgb2gray(data.astronaut())
  16. k = data.camera()
  17.  
  18. # size of blocks
  19. block_shape = (4, 4)
  20.  
  21. # see astronaut as a matrix of blocks (of shape block_shape)
  22. view = view_as_blocks(l, block_shape)
  23.  
  24. #for i in view:
  25. # print(i)
  26. # collapse the last two dimensions in one
  27. #flatten_view = view.reshape(view.shape[0], view.shape[1], -1)
  28. for i in view:
  29. plt.imshow(i)
  30. plt.show()
  31.  
  32.  
  33. #print(flatten_view.shape)
  34.  
  35. print(l.shape)
  36. print(k.shape)
Add Comment
Please, Sign In to add comment