# 混合图像 result = np.zeros((h, w, ch), dtype=np.uint8) for row in range(h): for col in range(w): w1 = mask2[row, col] / 255.0 b, g, r = src[row, col] b1,g1,r1 = background[row, col] b = (1.0-w1) * b1 + b * w1 g = (1.0-w1) * g1 + g * w1 r = (1.0-w1) * r1 + r * w1 result[row, col] = (b, g, r)