Advertisement
Guest User

PythonProgram

a guest
Aug 30th, 2014
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import hashlib
  2. import Image
  3. from PIL import Image
  4.  
  5. import numpy as np
  6. import matplotlib.pyplot as plt
  7. import matplotlib.image as mpimg
  8.  
  9. def rgb2gray(rgb):
  10.     return np.dot(rgb[...,:3], [0.299, 0.587, 0.144])
  11.  
  12.  
  13. img = mpimg.imread('redg.jpg')    
  14. gray = rgb2gray(img)
  15. plt.imshow(gray, cmap = plt.get_cmap('gray'))
  16. plt.savefig('a.jpg')
  17.  
  18. image_file = Image.open('a.jpg')
  19. a = image_file.resize((9,8),Image.ANTIALIAS)
  20. a.save('scaled.jpg',optimize=True,quality=95)
  21. image_file1 = Image.open('scaled.jpg')
  22. width, height = image_file1.size
  23. pixels = list(image_file1.getdata())
  24.  
  25. def function():
  26.     difference = []
  27.     for row in xrange(height):
  28.         for col in xrange(width):
  29.             if col != width:
  30.                 difference.append(pixels[col+row] > pixels[(col+row)+1])
  31.                
  32.     for col in xrange(width-1):
  33.         foo = difference[col:col+(width-1)]
  34.         print foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement