使用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)

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

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

相关推荐
The Chosen One985几秒前
C++ : AVL树-详解
开发语言·c++
PH_modest11 分钟前
【Qt跬步积累】—— 初识Qt
开发语言·qt
怀旧,39 分钟前
【C++】18. 红⿊树实现
开发语言·c++
多恩Stone1 小时前
【3DV 进阶-2】Hunyuan3D2.1 训练代码详细理解下-数据读取流程
人工智能·python·算法·3d·aigc
xiaopengbc1 小时前
在 Python 中实现观察者模式的具体步骤是什么?
开发语言·python·观察者模式
Python大数据分析@1 小时前
python用selenium怎么规避检测?
开发语言·python·selenium·网络爬虫
ThreeAu.1 小时前
Miniconda3搭建Selenium的python虚拟环境全攻略
开发语言·python·selenium·minicoda·python环境配置
偷心伊普西隆1 小时前
Python EXCEL 理论探究:格式转换时处理缺失值方法
python·excel
zhangfeng11331 小时前
R 语法高亮为什么没有,是需要安装专用的编辑软件,R语言自带的R-gui 功能还是比较简单
开发语言·r语言