当前位置:   article > 正文

【opencv】无缝融合两张图片--cv2.seamlessClone()泊松融合

cv2.seamlessclone()

基于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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

im:
在这里插入图片描述

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

在这里插入图片描述
mixed_clone:

在这里插入图片描述

参考

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/81496
推荐阅读
相关标签
  

闽ICP备14008679号