import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
img_water = cv.imread("../SampleImages/waterdrop.jpg", cv.IMREAD_COLOR)
plt.imshow(img_water[:,:,::-1])
img_dog = cv.imread("../SampleImages/pomeranian.png", cv.IMREAD_COLOR)
plt.imshow(img_dog[:,:,::-1])
#图像加法
#cv.add(src1, src2, dst=None, mask=None, dtype=None) openCV的加法是饱和操作,大于255会维持255
#参考资料:https://blog.csdn.net/wenhao_ir/article/details/125246253
img_addition = cv.add(img_dog, img_water)
plt.imshow(img_addition[:,:,::-1])
#图像减法
#cv.subtract(src1, src2, dst=None, mask=None, dtype=None) openCV的减法也是饱和操作,小于0会维持0
#参考资料:https://blog.csdn.net/LaoYuanPython/article/details/109020778
img_subtraction = cv.subtract(img_dog, img_water)
plt.imshow(img_subtraction[:,:,::-1])
#图像乘法
#cv.multiply(src1, src2, dst=None, scale=None, dtype=None)
#参考资料: https://blog.csdn.net/LaoYuanPython/article/details/109105916
img_multiply = cv.multiply(img_dog, img_water)
plt.imshow(img_multiply[:,:,::-1])
#图像除法
#cv.divide(src1, src2, dst=None, scale=None, dtype=None)
#参考资料:https://blog.csdn.net/LaoYuanPython/article/details/109139636
img_divide = cv.divide(img_dog, img_water)
plt.imshow(img_divide[:,:,::-1])
文章来源:https://www.toymoban.com/news/detail-639878.html
文章来源地址https://www.toymoban.com/news/detail-639878.html
到了这里,关于Python Opencv实践 - 图像的加减乘除的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!