【opencv】无缝融合两张图片--cv2.seamlessClone()泊松融合
opencv
OpenCV: 开源计算机视觉库
项目地址:https://gitcode.com/gh_mirrors/opencv31/opencv
免费下载资源
·
基于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:
参考
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 天前
更多推荐
已为社区贡献6条内容
所有评论(0)