基于opencv-python=3.4.0
功能:将2张图片进行融合

# -*- coding: utf-8 -*-
"""
Created on Wed May 12 08:28:00 2021

@author: zqq
"""

import cv2
import numpy as np
 
folder = 'cv/'
# Read images : src image will be cloned into dst
im = cv2.imread("ds_ori/pic/doubleskin_134663_1_0.jpg")
obj = cv2.imread("ds_small/pic/doubleskindoubleskin_20210315_177240_3_32_0.jpg")
# Create an all white mask
mask = 255 * np.ones(obj.shape, obj.dtype)


# The location of the center of the src in the dst
width, height, channels = im.shape
center = (height // 2, width // 2)   # 融合的位置,可以自己设置
 
# Seamlessly clone src into dst and put the results in output
normal_clone = cv2.seamlessClone(obj, im, mask, center, cv2.NORMAL_CLONE)
mixed_clone = cv2.seamlessClone(obj, im, mask, center, cv2.MIXED_CLONE)
 
# Write results
# normal_clone 或者是 mixed_clone
cv2.imwrite(folder + "normal_merge.jpg", normal_clone)
cv2.imwrite(folder + "fluid_merge.jpg", mixed_clone)

im:
在这里插入图片描述

obj:
在这里插入图片描述
normal_clone:

在这里插入图片描述
mixed_clone:

在这里插入图片描述

参考

https://blog.csdn.net/leviopku/article/details/83658767

GitHub 加速计划 / opencv31 / opencv
77.38 K
55.71 K
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:2 个月前 )
48668119 dnn: use dispatching for Winograd optimizations 3 天前
3dace76c flann: remove unused hdf5 header 3 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐