[英]Using Python's pillow/PIL library:
In the following code I am trying to do the following by using Python's pillow/PIL library: 在以下代码中,我尝试通过使用Python的pillow / PIL库执行以下操作:
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. 这是我第一次使用Python的pillow / PIL库,我只是想澄清一下我是否正确实现了这两件事。
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.]]
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)
...
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.