Reputation: 167
In the following code I am trying to do the following by using Python's pillow/PIL library:
This is my first time using Python's pillow/PIL library and I just wanted to clarify if I have achieved these 2 things correctly.
Here my is my code I have produced:
import numpy as np
from PIL import Image
img = Image.open('house.jpg')
image = np.array(img)
arr[20,30]
red = np.float64(image[:,:, 0])
green = np.float64(image[:,:,1])
blue = np.float64(image[:,:,2])
and for instance, when I use
print(red)
I get the following output:
[[ 34. 41. 49. ... 22. 22. 22.]
[ 28. 34. 41. ... 23. 23. 23.]
[ 23. 26. 30. ... 24. 24. 24.]
...
[ 32. 45. 57. ... 105. 97. 109.]
[ 34. 32. 41. ... 100. 94. 113.]
[ 33. 36. 52. ... 99. 90. 113.]]
Upvotes: 1
Views: 198
Reputation: 207818
You could, more simply, use:
import numpy as np
from PIL import Image
img = Image.open('house.jpg')
image=np.array(img,dtype=np.float64)
...
...
Upvotes: 2