Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # imports
- %matplotlib inline
- import matplotlib.pyplot as plt
- import networkx as nx
- from ipywidgets import interact
- import matplotlib.image as mpimg
- import numpy as np
- # functions
- def get_image():
- f = mpimg.imread('images/Lenna.png')
- f = (f[:,:,0] + f[:,:,1] + f[:,:,2]) / 3
- return f
- def show_image(sample_factor, rep_factor):
- plt.figure()
- f = get_image()
- f = f[::sample_factor, ::sample_factor]
- f = np.tile(f, (rep_factor,rep_factor))
- imgplot = plt.imshow(f, cmap='Greys_r', interpolation='none')
- plt.show()
- interact(show_image, sample_factor=(2,50), rep_factor=(1,10));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement