Python Opencv实践 - 图像的加减乘除

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])

Python Opencv实践 - 图像的加减乘除_第1张图片

 Python Opencv实践 - 图像的加减乘除_第2张图片

 Python Opencv实践 - 图像的加减乘除_第3张图片

 Python Opencv实践 - 图像的加减乘除_第4张图片

 Python Opencv实践 - 图像的加减乘除_第5张图片

 Python Opencv实践 - 图像的加减乘除_第6张图片

 

你可能感兴趣的:(OpenCV实践-python,python,opencv,计算机视觉,图像处理,图像基础运算)