Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import numpy as np
- im = Image.open("/Users/Hugo/green_leaves.jpg")
- im.load()
- height, widht = im.size
- p = np.array([0,0,0])
- for row in range(height):
- for col in range(widht):
- a = im.getpixel((row,col))
- p = np.append(a.asarray())
- Traceback (most recent call last):
- File "/Users/hugo/PycharmProjects/Meteo API/image.py", line 17, in <module>
- p = np.append(a.asarray())
- AttributeError: 'tuple' object has no attribute 'asarray'
- from PIL import Image
- import numpy as np
- im = Image.open("/Users/Hugo/green_leaves.jpg")
- p = np.array(im)
- p = p.reshape(-1, p.shape[2])
- p=[]
- for row in range(height):
- for col in range(widht):
- a = im.getpixel((row,col))
- p.append(a)
- p=np.asarray(p)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement