import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
# 1读取图像
img1 = cv.imread("pic1.jpg")
img2 = cv.imread("pic2.jpg")
# 2加法操作
img3 = cv.add(img1, img2) # CV加法
img4 = img1 + img2 # 直接相加
# 3图像显示
plt.rc("font", family='Microsoft YaHei')
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 8), dpi=100)
axes[0].imshow(img3[:, :, ::-1])
axes[0].set_title("opencv的加法结果")
axes[1].imshow(img4[:, :, ::-1])
axes[1].set_title("直接相加结果")
plt.show()
# 1读取图像
img1 = cv.imread("pic1.jpg")
img2 = cv.imread("pic2.jpg")
# 2图像混合
img3 = cv.addWeighted(img1, 0.7, img2, 0.3, 0)
# 3图像显示
plt.figure(figsize=(8, 8))
plt.imshow(img3[:, :, ::-1])
plt.show()
THE END