在多个大图像上叠加一个小图像并将它们保存在不同的文件夹中

overlay a small image on multiple biger images and save them in a different folder

您好,我想在较大的图像上叠加或粘贴图像(有一个包含 10 张图像的文件夹,并且想在所有 10 张图像上叠加较小的图像)并将它们保存在不同的文件夹中。我确实尝试了一些东西,但是 运行 出错了。

import scipy.misc
import numpy as np
import os
import cv2

outPath = "C:\darkflow\Augmented Images\augmented_images\.."

cov = cv2.imread("C:\darkflow\Augmented Images\extracted\cover\extracted_cover.jpg")
bgs  = [cv2.imread(file) for file in glob.glob("C:\darkflow\Augmented Images\images\*.jpg")]

for bg in bgs:    
    bg[y_offset:y_offset+s_img.shape[0], x_offset:x_offset+s_img.shape[1]] = cov

    f_image = cv2.cvtColor(bg, cv2.COLOR_BGR2RGB)

    fullpath = os.path.join(outPath, 'augmented_'+ bg)

    misc.imsave(fullpath, f_image)

使用此代码我得到一个错误:ufunc 'add' 不包含签名匹配类型 dtype('

我在查看代码时找到了答案。我的密码是

from scipy import ndimage, misc
import scipy.misc
import numpy as np
import os
import cv2



cov = cv2.imread("C:\darkflow\Augmented Images\extracted\cover\extracted_cover.jpg")
bgs  = [cv2.imread(file) for file in glob.glob("C:\darkflow\Augmented Images\images\*.jpg")]
d=1
x_offset=100
y_offset= 100
for bg in bgs:    
    bg[y_offset:y_offset+ cov.shape[0], x_offset:x_offset+ cov.shape[1]] = cov
    filename =  "images/file_%d.jpg"%d
    cv2.imwrite(filename, bg)
    d+=1