【发布时间】:2020-08-02 13:52:06
【问题描述】:
我正在做一个项目来实现虚拟化妆。 我在使用眼线笔部分时遇到问题。
我应该如何更改 alpha 值(alpha_s,alpha_l)?在 Python 中?
我想调整 alpha 值,使脸部图像上的眼线可能不可见、可能看起来模糊,或者我想看清楚。
人脸图片来源是 YouTube '뽐뽐뽐' (Apink's Bomi)
下面是python代码,人脸的高宽,img都是一样的。
face = cv2.imread('./image/ex1.png')
img = cv2.imread('./result_3.png',-1) ## It is shaped like a left eyeliner and has a transparent background.
x_offset = y_offset = 0
alpha_s = img[:, :, 3] / 255.0
alpha_l = 1.0 - alpha_s
for c in range(0, 3):
face[y_offset:y_offset+img.shape[0], x_offset:x_offset+img.shape[1], c] = \
(alpha_s * img[:, :, c] + alpha_l * face[y_offset:y_offset+img.shape[0],
x_offset:x_offset+img.shape[1], c])
cv2.imshow('result', face)
cv2.waitKey(0)
cv2.destroyAllWindows()
'result_3.png' 图像看起来像这样。-> enter image description here
部分代码结果图片(左眼) -> enter image description here
请帮帮我。
【问题讨论】:
标签: python opencv image-processing