日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

目標檢測數據增強: python-opencv 將一張圖片融合到另一張圖片中

系統 2224 0
            
              #opencv批量泊松融合
import cv2
import numpy as np
import os

src_path = "cut_1/"
save_path = "mixup_1/"
dst = cv2.imread("beijing1.jpg")
a = dst.shape
H=a[0]
W=a[1]
print("H",H)
print("W",W)
imagelist = os.listdir(src_path)
print("222222",len(imagelist))

centers = ((600,600),(700,500),(800,300),(295,600),(300,450)) 
for center in centers:
	for image in imagelist:
		# print("11111111",image)
		image_pre, ext = os.path.splitext(image)
		img_file = src_path + image
		print("333333",img_file)
		src_img = cv2.imread(img_file)
		h = src_img.shape[0]
		w = src_img.shape[1]

		# 融合的圖片尺寸過大時,按比例壓縮,不改變寬高比 
		if h+center[1] > H or w+center[0] > W:
			print("aaaaaa")
			# src_img = cv2.resize(src_img, (int(h/1.5), int(w/1.5)))
			src_img = cv2.resize(src_img,(0, 0), fx=0.75, fy=0.75, interpolation=cv2.INTER_NEAREST)
			h = src_img.shape[0]
			w = src_img.shape[1]
			if h+center[1] > H or w+center[0] > W:
				print("bbbbbb")
				src_img = cv2.resize(src_img,(0, 0), fx=0.75, fy=0.75, interpolation=cv2.INTER_NEAREST)
				h = src_img.shape[0]
				w = src_img.shape[1]
				if h+center[1] > H or w+center[0] > W:
					print("ccccc")
					src_img = cv2.resize(src_img,(0, 0), fx=0.75, fy=0.75, interpolation=cv2.INTER_NEAREST)
					h = src_img.shape[0]
					w = src_img.shape[1]
					if h+center[1] > H or w+center[0] > W:
						print("ddddd")
						src_img = cv2.resize(src_img,(0, 0), fx=0.75, fy=0.75, interpolation=cv2.INTER_NEAREST)
						h = src_img.shape[0]
						w = src_img.shape[1]
						if h+center[1] > H or w+center[0] > W:
							print("eeeee")
							src_img = cv2.resize(src_img,(0, 0), fx=0.75, fy=0.75, interpolation=cv2.INTER_NEAREST)
							h = src_img.shape[0]
							w = src_img.shape[1]

		src_mask = 255*np.ones(src_img.shape, src_img.dtype)
		normal_clone = cv2.seamlessClone(src_img, dst, src_mask, center, cv2.NORMAL_CLONE)
		cv2.imwrite(save_path + image_pre + str(int(center[0]/100)) + ".jpg", normal_clone)
            
          

opencv實現無縫融合--seamless clone

python opencv 將一張圖片無縫合成到另一張圖片中


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 寻乌县| 光山县| 吉木乃县| 招远市| 礼泉县| 大兴区| 苏州市| 宝山区| 黑河市| 佛坪县| 左贡县| 应城市| 公主岭市| 霍城县| 拉萨市| 什邡市| 来安县| 隆德县| 嵊泗县| 九龙城区| 临武县| 九江市| 黄陵县| 慈溪市| 宁波市| 韶山市| 龙陵县| 专栏| 邵武市| 冀州市| 永泰县| 武强县| 丁青县| 大悟县| 阿城市| 额敏县| 鄢陵县| 汾阳市| 阜新| 遂平县| 图们市|