如何在 python 中的图像上添加文本以及一些饱和度和亮度调整?
How can I add text over an image in python along with some saturation and brightness adjustments?
我对 python 中的编码还很陌生,我想知道我是否可以编写一个脚本来创建像 this
这样的图像
PIL 可以吗?如果是,如何?
OpenCV可以做到这一点,参考它的文档:http://docs.opencv.org/3.1.0/dc/da5/tutorial_py_drawing_functions.html and http://docs.opencv.org/trunk/d3/dc1/tutorial_basic_linear_transform.html
这应该让你开始:
import numpy as np
import cv2
img = np.zeros((512,512,3), np.uint8)
cv2.rectangle(img,(512,0),(0,512),(0,255,0),20)
font = cv2.FONT_HERSHEY_PLAIN
cv2.putText(img,'HELLO WORLD!',(10,250), font, 4,(255,255,255),2)
image=cv2.cv.fromarray(img)
cv2.cv.SaveImage('pic.jpg', image)
我对 python 中的编码还很陌生,我想知道我是否可以编写一个脚本来创建像 this
这样的图像PIL 可以吗?如果是,如何?
OpenCV可以做到这一点,参考它的文档:http://docs.opencv.org/3.1.0/dc/da5/tutorial_py_drawing_functions.html and http://docs.opencv.org/trunk/d3/dc1/tutorial_basic_linear_transform.html
这应该让你开始:
import numpy as np
import cv2
img = np.zeros((512,512,3), np.uint8)
cv2.rectangle(img,(512,0),(0,512),(0,255,0),20)
font = cv2.FONT_HERSHEY_PLAIN
cv2.putText(img,'HELLO WORLD!',(10,250), font, 4,(255,255,255),2)
image=cv2.cv.fromarray(img)
cv2.cv.SaveImage('pic.jpg', image)