<分区>
我想知道,在 python 中用 x 和 y 值绘制像素的最简单方法是什么?
标签 python
<分区>
我想知道,在 python 中用 x 和 y 值绘制像素的最简单方法是什么?
最佳答案
可能最简单的方法是使用 PIL (Python 图像库)只需 4 行即可实现:
from PIL import Image, ImageColor
im = Image.new('1', (1,1)) # create the Image of size 1 pixel
im.putpixel((0,0), ImageColor.getcolor('black', '1')) # or whatever color you wish
im.save('simplePixel.png') # or any image format
文档显示了许多其他自定义方法 http://pillow.readthedocs.io/en/3.4.x/reference/Image.html#examples .
关于python - 在 python 中绘制像素的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44190901/
相关文章:
python - 使用 .pth 以编程方式附加到 VirtualEnv 中的 PYTHONPATH
python - TensorFlow 1.8.0,急切执行和比较的行为不符合预期
javascript - 无法从 selenium execute_script 访问 chrome 消息传递 API
python - 序列化器: Customising nested relationships
python - 在 mac 中使用 python 为 safari 浏览器设置 selenium
python - pandas 通过递增最后一个值来回填 NaN