Advertisement
Guest User

Untitled

a guest
May 27th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. from matplotlib import pyplot as plt
  2. from matplotlib import image as mpimg
  3. import numpy as np
  4. import itertools
  5. from skimage import color
  6.  
  7.  
  8. img = color.rgb2gray(mpimg.imread("/home/henrik/pictures/grayscale_bench.png"))
  9. pyimg = img.tolist()
  10.  
  11. mergedlist = list(itertools.chain(*pyimg))
  12.  
  13.  
  14. for x in mergedlist:
  15.     if x < 0.51:
  16.         mergedlist[x] = 0
  17.     else:
  18.         mergedlist[x] = 1
  19.  
  20.  
  21. print(mergedlist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement