赞
踩
基于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:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。