Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import Image
- from PIL import Image
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.image as mpimg
- def rgb2gray(rgb):
- return np.dot(rgb[...,:3], [0.299, 0.587, 0.144])
- img = mpimg.imread('redg.jpg')
- gray = rgb2gray(img)
- plt.imshow(gray, cmap = plt.get_cmap('gray'))
- plt.savefig('a.jpg')
- image_file = Image.open('a.jpg')
- a = image_file.resize((9,8),Image.ANTIALIAS)
- a.save('scaled.jpg',optimize=True,quality=95)
- image_file1 = Image.open('scaled.jpg')
- width, height = image_file1.size
- pixels = list(image_file1.getdata())
- def function():
- difference = []
- for row in xrange(height):
- for col in xrange(width):
- if col != width:
- difference.append(pixels[col+row] > pixels[(col+row)+1])
- for col in xrange(width-1):
- foo = difference[col:col+(width-1)]
- print foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement