Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import skimage
- from skimage import data
- from skimage import color
- from skimage.util import view_as_blocks
- import matplotlib.pyplot as plt
- import numpy as np
- from skimage.feature import corner_harris, corner_peaks
- import os
- filename = os.path.join(skimage.data_dir, 'moon.png')
- from skimage import io
- moon = io.imread(filename)
- # get astronaut from skimage.data in grayscale
- l = color.rgb2gray(data.astronaut())
- k = data.camera()
- # size of blocks
- block_shape = (4, 4)
- # see astronaut as a matrix of blocks (of shape block_shape)
- view = view_as_blocks(l, block_shape)
- #for i in view:
- # print(i)
- # collapse the last two dimensions in one
- #flatten_view = view.reshape(view.shape[0], view.shape[1], -1)
- for i in view:
- plt.imshow(i)
- plt.show()
- #print(flatten_view.shape)
- print(l.shape)
- print(k.shape)
Add Comment
Please, Sign In to add comment