使用Python CV2融合人脸到新图片--优化版

优化说明

上一版本人脸跟奥特曼图片合并后边界感很严重,于是查找资料发现CV2还有一个泊松函数很适合融合图像。具体代码如下:

python 复制代码
import numpy as np
import cv2
 
usrFilePath = "newpic22.jpg"
atmFilePath = "atm2.jpg"
src = cv2.imread(usrFilePath)
dst = cv2.imread(atmFilePath)
 
src_mask = 255 * np.ones(src.shape, src.dtype)
center = (200,180)
output = cv2.seamlessClone(src, dst, src_mask, center, cv2.NORMAL_CLONE)

cv2.imencode('.jpg', output)[1].tofile(r'add_img.jpg')
cv2.imshow('output', output)
cv2.waitKey(0)

我们来看看本次融合后的效果图:

感觉边界感没有之前那么明显了,算是比较合适的一次融合。

相关推荐
Warson_L9 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅9 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅9 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L9 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅10 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L10 小时前
python的类&继承
python
Warson_L10 小时前
类型标注/type annotation
python
ThreeS13 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵14 小时前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏