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

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

系統 2289 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條評論
主站蜘蛛池模板: 色达县| 上虞市| 固原市| 沈阳市| 右玉县| 西安市| 油尖旺区| 通化市| 永德县| 历史| 丹巴县| 南雄市| 太仓市| 驻马店市| 临夏县| 宁强县| 枣阳市| 江孜县| 苗栗县| 普陀区| 称多县| 博爱县| 中超| 沂南县| 永平县| 鄂托克前旗| 张家港市| 遵义县| 维西| 九龙城区| 安平县| 泰兴市| 南汇区| 建湖县| 井陉县| 定结县| 沛县| 保康县| 定襄县| 万源市| 南康市|